cancel
Showing results for 
Search instead for 
Did you mean: 

Use of timers with large software

ivancolla9
Associate III
Posted on September 13, 2016 at 15:16

Good day to everyone,

I am writing here in order to have some suggestions on the use of timers. 

I am writing a spc5 application whee I have a lot of operations and I must do various things at specific moments. For example, I have to change the vlaue of a pin every millisecond.

In order to do this, I read the value of the counter in STM module and use that in a code like the following.

if ( (STM.CNT.R - startTime)  > ONE_MILLISECOND) 

{ /* Do operation. */}

startTime is initialized with the startting value of the STM.CNT.R counter. Then I use the statement to verify when a number of counter ticks corresponding to 1 ms is passed.

The problem is that I have many operations. So, when the code returns to the above statement, more than 1 ms is already passed. Obviously the condition is verified and the code in the if block is executed, but too late.

Somebody has some suggestion on how this type of problem can be resolved?

Thanks,

Ivan 

#spc56-timer
1 REPLY 1
Erwan YVIN
ST Employee
Posted on September 14, 2016 at 12:31

Hello Ivan ,

You should use the Interruption Handler Mecanism.

We have some examples on RLA Applications by configuration in the Application Wizard Repository (5.0.1)

Best regards

Erwan

________________

Attachments :

2016-09-14_122909.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006qXZh&d=%2Fa%2F0X0000000bor%2FHLv3YBxPdTs5H_uXu5oBDfMu4VSgSSScaG8hDi1UBwk&asPdf=false