|
|
View previous topic :: View next topic |
Author |
Message |
joseph20480
Joined: 21 Dec 2011 Posts: 42
|
Timer2 on pic 18f4550 with PLL5 (USB) |
Posted: Sun Feb 19, 2012 2:29 pm |
|
|
Hi,
I use a pic 18f4550 with a 20Mhz cristal... with fuses and code from CCS, I'm able to communicate in CDC mode with the pc (PLL for USB).
Code: | #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,PUT,BROWNOUT
#use delay(clock=48M) |
Now, i could use interruption of timer2 for generate a pwm signal... But i can't setting it correctly.
Code: | setup_timer_2(T2_DIV_BY_1,1,1);
set_timer2(0);
enable_interrupts(global);
enable_interrupts(INT_TIMER2); |
T2_div_by_1 or T2_div_by_16.... any change...I don't understand what happen... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sun Feb 19, 2012 3:40 pm |
|
|
Also, as a comment, if you did want to use an interrupt off timer2 (nothing to do with PWM), the values used would prevent the chip doing _anything_ useful.
T2_DIV_BY_1 means run timer2, off the master oscillator/4 (one instruction per count). Then you are telling the timer to reset after just 2 counts (the '1' in the next location, plus one), and to interrupt every time the timer resets (the final '1'). Result, would be an interrupt every 2 instructions. Since it takes about 60 instructions to actually get into and out of an interrupt handler, the chip would sit permanently jumping into the interrupt handler.....
Ouch...
Best Wishes |
|
|
|
|
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
|