AnsweredAssumed Answered

Time measurement

Question asked by Julian Cox on Jul 3, 2017
Latest reply on Jul 21, 2017 by ZhangJennie

I am having a problem with time measurement in an application that I am developing using a S08SH. I am using (Processor Expert) FC1:FreeCntr with timer TPM10 to generate an interrupt every 5mS. This works fine. I am then trying to use  FC161:FreeCntr16 with timer TPM20 to measure a time interval: -

In the FC1:FreeCntr ISR I start the FC161 timer. A separate software event stops the timer and I read the elapsed time - except that it doesn't work.

To investigate the problem I created a simple simulation project. 

void FC1_OnInterrupt(void)


unsigned char r,s;

unsigned int Time;

r = FC161_Enable();

for(s=0;s<50;s++);      // a simple delay loop

Time = TPM2CNT;      // read the ticks

r = FC161_Reset();     // set the breakpoint here

r = FC161_Disable();


The value in TPM2CNT was always wrong and the only it would work was if I set a breakpoint somewhere in the ISR and then manually changed registers TPM20SC from 0xD0 to 0x50 and TPM2MOD from 0x0003 to 0xFFFF.

TPM2CNT then held a value that related to the duration of the simple delay loop. However, I cannot find a way to set these register values for FC161:FreeCntr16 using the component Inspector in Processor Expert.