View previous topic :: View next topic |
Author |
Message |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
24FJ64002 FRC trouble |
Posted: Thu Sep 23, 2010 3:09 am |
|
|
Hi everyone,
I'm using a 24FJ64GA002 with its internal fast RC oscillator. My problem is that the clock frequency (as measured on OSCO/pin10) is half the frequency it should be. My fuses: Code: | #fuses FRC_PLL, NOWDT
#fuses NOJTAG, NOPROTECT, NOWRT, NODEBUG, NOCKSFSM
#fuses NOOSCIO, NOIESO
#use delay(clock=32000000) | As per the fuses and the datasheet, I should see Code: | (FRC=8MHz)*(4xPLL)/2=16MHz | on OSCO. Throwing a scope onto the pin shows me only 8MHz.
The datasheet tells me that RCDIV0 (bit 8) in register CLKDIV (0x0744) defaults to 1. So I got around this issue by using this in my code: Code: | #word CLKDIV = 0x0744
.
.
CLKDIV=0; | Now I see a 16MHz clock on OSCO. But there must be a more elegant way to do this. What surprises me is the fact that the postscaler is 'engaged' in the first place. The datasheet (and the CCS fuse descriptions) gave me the impression that the postscaler block is by-passed when FRC_PLL is selected. Maybe my fuses are messed up.
Additionally, I can't seem to find any fuses to set the exact FRC postscaler ratio - there's just "FRC_PS". How do I set the ratio (other than doing it the way I adjusted RCDIV0.
MPLAB v8.30 / PCD v4.104
Rohit |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Sep 23, 2010 6:46 am |
|
|
Quote: | The datasheet (and the CCS fuse descriptions) gave me the impression that the postscaler block is by-passed when FRC_PLL is selected. |
Figure 7-1 clock diagram shows the opposite, I think.
Quote: | I can't seem to find any fuses to set the exact FRC postscaler ratio | Look at the configuration bits section in the datasheet - there are none. CLKDIV has to be setup in most cases to achieve the intended clock parameters. PCD #use delay is doing this partly, but I'm not sure with GA002 chip. Possibly an extended syntax like #use delay (oscillator=8Mhz, clock=32Mhz) is required. But I would always check the CLKDIV setting done by the compiler. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Thu Sep 23, 2010 7:01 am |
|
|
Quote: | Possibly an extended syntax like #use delay (oscillator=8Mhz, clock=32Mhz) is required | Bingo! The exact code is: Code: | #use delay (internal=8Mhz, clock=32Mhz) | Thanks!
Rohit |
|
|
|