eTPU-CRANK-API Documentation
The eTPU CRANK APIs etpu_crank.c/.h includes API functions for eTPU function CRANK, typically used together with CAM in an engine position system.
The CRANK eTPU function uses 1 eTPU channel to process the tooth signal from a crankshaft sensor and generate the eTPU-internal angle-base (TCR2). The CRANK eTPU function uses the Enhanced Angle Counter (EAC) eTPU hardware. The CRANK eTPU function can be assigned to one of:
- eTPU channel 0, input signal connected to TCRCLK
- eTPU channel 1, input signal connected to channel 1 input (eTPU2 only)
- eTPU channel 2, input signal connected to channel 2 input (eTPU2 only) Remember to set the TBCR.AM field correspondingly.
Features:
- Based on the selected polarity, either raising or falling signal transitions are detected.
- There are various tooth patterns supported:
- single gap
- multiple equally spaced gaps
- an additional tooth instead of a gap
- The tooth pattern is described by
- number of teeth between two gaps (teeth_till_gap),
- number of missing teeth in one gap (teeth_in_gap) and
- number of teeth per one engine cycle (teeth_per_cycle).
- An additional tooth instead of a gap is characterized by teeth_in_gap = 0.
- The number of angle-base counts per one tooth is configurable (ticks_per_tooth).
- The gap is recognized using an ABA test, see gap_ratio.
- A noise imunity and check of unexpected acceleration/deceleration are achieved using tooth windows (win_ratio_normal, win_ratio_across_gap, win_ratio_after_gap, win_ratio_after_timeout)
- The measured tooth periods can optionally be logged to an array.
- The CRANK state and the global engine position state are handled. The CRANK state can be one of:
- 8 error conditions are reported:
- Channel interrupt is generated when:
- the global engine position state has been changed.
- once per engine cycle, on the first tooth, in full synchronization state (FS_ETPU_ENG_POS_FULL_SYNC).
- during synchronization, when the CAM log buffer is ready.
The Synchronization of eTPU TCR2 angle counter to the physical rotation of the crank wheel is, from the software point of view, result of a sequence of processing on both the eTPU and the CPU site:
- eTPU function CRANK recognizes the gap or the additional tooth on the crank wheel. eng_pos_state is set to HALF_SYNC.
- eTPU function CAM starts to log cam signal transitions. It last for for teeth_per_sync crank teeth. After that CRANK sets channel interrupt flag. eng_pos_state is set to PRE_FULL_SYNC.
- On the CRANK interrupt, the CPU can use the Cam Log to decode the engine position at the interrupt (at the first tooth after gap). The CPU writes the decoded position (TCR2 engine angle), using fs_etpu_crank_set_sync.
- eTPU function CRANK adjusts the engine angle TCR2 value and sets eng_pos_state to FULL_SYNC. The full synchronization is achieved.