CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Not sure why pulse period not looks the same as code?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
prakasit_man



Joined: 18 Jul 2013
Posts: 4

View user's profile Send private message Send e-mail

Not sure why pulse period not looks the same as code?
PostPosted: Wed Aug 21, 2013 4:11 am     Reply with quote

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: 19552

View user's profile Send private message

PostPosted: Wed Aug 21, 2013 5:07 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 21, 2013 9:54 am     Reply with quote

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! Very Happy
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Wed Aug 21, 2013 4:42 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 21, 2013 10:22 pm     Reply with quote

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: 1358

View user's profile Send private message

PostPosted: Thu Aug 22, 2013 3:32 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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