Timer Functionality

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
PPK
Posts: 18
Joined: 08 Jan 2018 06:27

Timer Functionality

#1 Post by PPK » 31 Jan 2018 02:39

Hi,

I do not see a general Timer capability in the compiler.

As an example, I wish to have a few timers within my application for timeouts of user inputs, comms etc.
I would normally use say a 1mS timer SystemTimer and within this timer, decrement variables etc.
Other compilers I have used would allow the declaration and addition of a variable and the SystemTimer would automatically decrement this variable to 0.
Sample compiler types / functions
SysTimer RxMessTimer;
SetSysTimerM(RxMessTimer, 100); // = 100mS Count down timer
char GetSysTimer(RxMessTimer) ie if(GetSysTimer(RxMessTimer) == 0){...
char isSysTimerZero(PCCommsWDTimer) ie if (isSysTimerZero(PCCommsWDTimer)){


I'm using a Mega2560 and cannot find any code for creating Timers/Interrupt routines for this.
Ideas?
Thanks,
Neil.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Timer Functionality

#2 Post by dusan.poluga » 01 Feb 2018 13:38

Hi,

A timer interrupt initialization code can be generated from our Timer Calculator application.

On the left side of the application you would need to select the device that you are working with, the clock frequency that your micro controller is set to run at,
the timer that you want to generate the initialization code for and the time that you want the timer interrupt to execute.

After you set the mentioned settings you need to press the calculate button and the code for mikroC,Basic and Pascal will be generated on the right side.

Best Regards,
Dusan Poluga.

Post Reply

Return to “mikroC PRO for AVR General”