Forum - MCS Electronics
View previous topic :: View next topic
Author
Message
nicofer Joined: 01 May 2013 Posts: 90 Location: GRJ
Posted: Fri Jan 17, 2014 9:30 am Post subject: Timer 0 ,2
Hi
I know there are lots of posts and info about timers and interrupts but I have a problem with Timer 0 ,2
I use timer 1 as a pwm timer so that leave me Timer 0 or timer 2 for periodic system interrupt,
I also use Config Clock = Soft to use time functions
The cpu is an at90can32 or 128
My problem is that the timer0 count does not increment , and if I try to use timer2 I get the error : 249 ISR already defined SOFTCLOCK
Here is the timer0 config part :
Config Timer0 = Timer , Prescale = 1024
On Ovf0 Time0e
Enable Timer0
Enable Interrupts
The isr
Time0e:
Toggle Yellowled
Return
In the main loop I have :
Print #2 , Tcnt0
for debugging and the value stay on " 0 " - it does not increment , and also the LED does not toggle .
What am I missing to get this running.
The plan is to get an interrupt each time the timer 0 overflow , with a 16 MHz crystal and 1024 prescale and 8 bit count it should be about 60Hz ?
Cheers
Nico
Back to top
bgardner Joined: 09 Apr 2004 Posts: 46 Location: Everett, WA
Posted: Sun Jan 26, 2014 4:23 am Post subject:
Hi Nico,
Here's how I configure a Timer to do something like what you're doing.
Code:
Config Timer2 = Timer , Prescale = 1024 , Clear Timer = 1
On Oc2a Timer2_isr 'point to interrupt routine
'load preset, enable, and start timer2
Ocr2a = &H C3 'configure preset of 125
Enable Oc2a 'enable interrupt
Start Timer2 'and start timer
Hope this helps.
Bob
Back to top
enniom Joined: 20 Oct 2009 Posts: 537
Posted: Mon Jan 27, 2014 10:46 pm Post subject:
Nico,
do not have the chip to test fully ... but as a minimum I suggest including:
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum