|
|
View previous topic :: View next topic |
Author |
Message |
juandres
Joined: 23 Jun 2011 Posts: 5 Location: Ecuador
|
dspic30f4011 set_timer2() does't work |
Posted: Tue Apr 09, 2013 6:36 pm |
|
|
I still programing dspic (tmr2) with this function and doesn't work!!! I think it is a bug because I treat tmr1 with set_timer1() and work perfectly. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Wed Apr 10, 2013 12:32 am |
|
|
Timer1, is different from all the other timers on the DSPIC's.
The timers above this, can be used individually, or 'paired' to form 32bit timers.
Unlike the PIC16/18 16bit timers, where the timer counts to 0xFFFF, then resets to zero, these timers can be programmed to reset themselves at a specific count, so setting a timer 'to' a value should never really be needed.
Setting 'to' a value won't work at all if you are above the reset point.
So what you can do, depends on how you have the timer configured.
Post a tiny (half dozen line) program showing what you are trying to do, and your compiler version number.
Best Wishes |
|
|
juandres
Joined: 23 Jun 2011 Posts: 5 Location: Ecuador
|
|
Posted: Wed Apr 10, 2013 2:30 am |
|
|
I want to program a fastest embedded application, this is the reason that I need to reprogrammed the timer2 each interrupt. I cannot post all the code but this has the same result for the purpose.
The fuses and configurations are:
Code: |
#include <30F4011.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES FRC_PLL16 //Internal Fast RC oscillator with 16X PLL
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOPUT //No Power Up Timer
#FUSES BORV27 //
#FUSES BROWNOUT //brownout reset
#use delay(clock=117920000) //7.37Mhz x16
|
Ttelmah wrote: | Timer1, is different from all the other timers on the DSPIC's.
The timers above this, can be used individually, or 'paired' to form 32bit timers. |
Yes, this explain in the datasheet.
This is the code for the timers
Code: |
setup_timer1(TMR_INTERNAL|TMR_DIV_BY_8,65535);//87.4 ms overflow
setup_timer2(TMR_INTERNAL|TMR_DIV_BY_256,2046);//
enable_interrupts(int_timer1);
enable_interrupts(int_timer2);
|
This is the code for the interrupts
Code: |
#int_TIMER1
void TIMER1_isr(void){
set_timer1(30000);
output_toggle(iny_out);
}
#int_TIMER2
void TIMER2_isr(void){
set_timer2(1000);
output_toggle(bob_out);
} |
The code works OK in TMR1.
The TMR2 I think that is configure correctly because I do not use the "TMR_32_BIT". The TMR2 and TMR 3 does not concatenate. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Wed Apr 10, 2013 2:56 am |
|
|
What I can't see is 'why' you'd want to do this. Just reduce the reset count point by 1000, and let the counter run.....
However, what makes you think it isn't working?. TMR2 is at address 0x106, and this line merrily generates the code:
Code: |
.................... set_timer2(1000);
0020E: MOV #3E8,W4
00210: MOV W4,106
|
Putting 1000, into address 106 correctly.
Have tried the last half dozen compilers and they all generate the correct code. |
|
|
juandres
Joined: 23 Jun 2011 Posts: 5 Location: Ecuador
|
|
Posted: Wed Apr 10, 2013 3:04 am |
|
|
Ttelmah wrote: | What I can't see is 'why' you'd want to do this. Just reduce the reset count point by 1000, and let the counter run.....
However, what makes you think it isn't working?. TMR2 is at address 0x106, and this line merrily generates the code:
Code: |
.................... set_timer2(1000);
0020E: MOV #3E8,W4
00210: MOV W4,106
|
Putting 1000, into address 106 correctly.
Have tried the last half dozen compilers and they all generate the correct code. |
I did this code in 4.104 and 4.141. Doesn't work.
Yes, I know that. I do this too
Code: |
#word TMR2 = 0x0106
|
And in the interrupt I prove this:
It is not work too. |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|