View previous topic :: View next topic |
Author |
Message |
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sat Dec 31, 2016 12:34 am Post subject: Timer difference between Mega128 and Mega2561 |
|
|
I am porting some code that works fine on an M128. In particular, using the RTC and one of the timers to generate an interrupt.
Code: | Config Clock = Soft , Gosub = SECTIC
Config Date = MDY , Separator = .
Config Timer2 = Timer , Prescale = 1024
On OVF2 SECTICTENTHS
Enable Timer2 |
So when recompiling for the M2561, I (of course) receive an error about the INT already being used
Quote: | Error : 249 Line : 52 ISR already defined [SECTICTENTHS] , in File :
|
Ok fine, HELP tells me that Timer2 might be used for a soft clock. Fine, let's change which timer we use:
Code: | Config Clock = Soft , Gosub = SECTIC
Config Date = MDY , Separator = .
Config Timer1 = Timer , Prescale = 1024
On OVF1 SECTICTENTHS
Enable Timer1 |
The above compiles (and loads) without error however the timer doesn't actually run.
What am I missing?
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sat Dec 31, 2016 1:43 am Post subject: |
|
|
Timer2 is 8Bit and overflow after (256 ticks * 1024 Prescale)=262144 ticks
Timer1 is 16Bit and overflow after (65536 ticks * 1024 Prescale)=67 108864 ticks
I think You can use Timer0 8Bit if its free, or you must configure Timer1 for wanted period (preload it or use Compare mode) |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sat Dec 31, 2016 3:51 am Post subject: |
|
|
EDC wrote: | Timer2 is 8Bit and overflow after (256 ticks * 1024 Prescale)=262144 ticks
Timer1 is 16Bit and overflow after (65536 ticks * 1024 Prescale)=67 108864 ticks
I think You can use Timer0 8Bit if its free, or you must configure Timer1 for wanted period (preload it or use Compare mode) |
Ahhh I see, thanks
Another fast question if you don't mind... do you know which timer the software UART uses for its timing? I'm trying to track down a different issue (guess I could start a new thread about it if that's a better way to go) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Dec 31, 2016 11:03 am Post subject: |
|
|
SW UART is not using any timer. _________________ Mark |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sat Dec 31, 2016 6:04 pm Post subject: |
|
|
albertsm wrote: | SW UART is not using any timer. |
Thanks Mark, that is helpful.
Have a great New Years |
|
Back to top |
|
|
|