Hi,
The S32 DS uses the engine control eTPU of the MPC5777.
I set it up as below.
#define SYS_FREQ_HZ 160E6
#define TCR1_FREQ_HZ (SYS_FREQ_HZ/2)
#define TEETH_TILL_GAP 58
#define TEETH_IN_GAP 2
#define TEETH_PER_CYCLE 120
#define TCR2_TICKS_PER_TOOTH 600 // 600 1000
#define TCR2_TICKS_PER_CYCLE ((TEETH_PER_CYCLE)*(TCR2_TICKS_PER_TOOTH))
#define MSEC2TCR1(x) (TCR1_FREQ_HZ/1E3*(x)/1E0)
#define USEC2TCR1(x) (TCR1_FREQ_HZ/1E3*(x)/1E3)
#define NSEC2TCR1(x) (TCR1_FREQ_HZ/1E3*(x)/1E6)
#define DEG2TCR2(x) ((x)*TCR2_TICKS_PER_CYCLE/720)
#define UFRACT24(x) ((x)*0xFFFFFF)
I put the RPM in 3000 and made it work. I understand that RPM is the same as crank rotation for 1 minute, but the crank frequency came out to be about 25Hz.
RPM = 25Hz * 60 = 1500 Half of what RPM put in.
How am I supposed to understand?
#define TCR1_FREQ_HZ (SYS_FREQ_HZ/2)
I don't know why this is TCR1 half of SYS. In the AN4908 example, it was a one-to-one ratio.
I don't know a lot because I received the completed project.
With eTPU2 it can be 1:1 ratio, but eTPU uses 1:2 ratio.
Example code apparently uses backward compatible code
Thank you,
I set the RPM, but the RPM comes out in half. What's wrong?
#define RPM2TP(x) (TCR1_FREQ_HZ/(x)*60/(TEETH_PER_CYCLE/2))
I put the value through RPM2TP, is the above definition wrong?