Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Timer 0 ,2

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP
View previous topic :: View next topic  
Author Message
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Fri Jan 17, 2014 9:30 am    Post subject: Timer 0 ,2 Reply with quote

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
View user's profile
bgardner

Bascom Member



Joined: 09 Apr 2004
Posts: 46
Location: Everett, WA

usa.gif
PostPosted: Sun Jan 26, 2014 4:23 am    Post subject: Reply with quote

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 = &HC3                                                'configure preset of 125
Enable Oc2a                                                 'enable interrupt
Start Timer2                                                'and start timer
 


Hope this helps.

Bob
Back to top
View user's profile Visit poster's website
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Mon Jan 27, 2014 10:46 pm    Post subject: Reply with quote

Nico,

do not have the chip to test fully ... but as a minimum I suggest including:

Code:
Start Timer0
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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