View previous topic :: View next topic |
Author |
Message |
prakasit_man
Joined: 18 Jul 2013 Posts: 4
|
Not sure why pulse period not looks the same as code? |
Posted: Wed Aug 21, 2013 4:11 am |
|
|
Dear All experts
Now I am using PIC24FJ16GA002 with CCS C compiler (PCWHD). I have written a simple program Blink LED at port B1.
ON/OFF period is 1 ms. But the output that I got on oscilloscope is "3 ms" not as planned at 1 ms both of on and off.
I have connected 30MHz crystal at pin 9(OSCI) and pin 10(OSCO). Both of this pin have a 22 pF ceramic capacitor connected to the ground.
Below is my code. Could you please advise what I am wrong and which statement I should edit? Is it suspecting on FUSES configuration?
Code: |
#include <24FJ16GA002.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is enabled
#FUSES XT
#device ICSP=1
#use delay(crystal=30MHz)
#define LED PIN_B1
#define DELAY 1
void main()
{
//Example blinking LED program
while(true)
{
output_low(LED);
delay_ms(DELAY);
output_high(LED);
delay_ms(DELAY);
}
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Aug 21, 2013 5:07 am |
|
|
Read the data sheet.
Table 27-15.
What is the maximum crystal frequency allowed with 'XT'?.
Even the fast (HS) oscillator only supports 30MHz over part of it's voltage range.
Anything over 24Mhz, you really need to be using the PLL. |
|
|
prakasit_man
Joined: 18 Jul 2013 Posts: 4
|
|
Posted: Wed Aug 21, 2013 9:54 am |
|
|
Ttelmah wrote: | Read the data sheet.
Table 27-15.
What is the maximum crystal frequency allowed with 'XT'?.
Even the fast (HS) oscillator only supports 30MHz over part of it's voltage range.
Anything over 24Mhz, you really need to be using the PLL. |
Thank you so very much, the program works now! |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Wed Aug 21, 2013 4:42 pm |
|
|
As a point of interest, for those series of chips, you also should specify another fuse. Most PIC24FJyyGAxxx chips use a combination of two fuses to set the oscillator. You should, as a point of good design, also specify the PR fuse so it is set properly. It's probably the default since your stuff works, but it is always good to specify. You can find it in the list of valid fuses included with PCWHD (I think the view menu) |
|
|
prakasit_man
Joined: 18 Jul 2013 Posts: 4
|
|
Posted: Wed Aug 21, 2013 10:22 pm |
|
|
jeremiah wrote: | As a point of interest, for those series of chips, you also should specify another fuse. Most PIC24FJyyGAxxx chips use a combination of two fuses to set the oscillator. You should, as a point of good design, also specify the PR fuse so it is set properly. It's probably the default since your stuff works, but it is always good to specify. You can find it in the list of valid fuses included with PCWHD (I think the view menu) |
Thank you again jeremiah. I have noted that and I shall use PR fuse as recommended. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Thu Aug 22, 2013 3:32 pm |
|
|
Something I didn't catch earlier cause you said it was working but I didn't see if you said you ended up using the PLL or not, but the PR fuse would be for external crystal no PLL. For external crystal with PLL, I *think* it is PR_PLL, but check the valid fuses in the IDE just in case. |
|
|
|