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

Timing Differences

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



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

Timing Differences
PostPosted: Mon Jul 05, 2010 3:57 pm     Reply with quote

Hi,

I'm trying create the standard blinking led circuit. I've written my program and it works however my logic analyser is telling the pin is changing value every 5 seconds not 500ms.

The clock value is set according to the PIC's (12f590) datasheet and when divided by 10 to compensate my programmer (PICKIT 2) detects an invalid OSCCAL value and the Pic refuses to accept the new program.

Any ideas?

Cheers,

Code:

#include <12f509.h>

#use delay (clock=40000000)
#fuses  NOMCLR, NOWDT, NOPROTECT, INTRC
#define OUTPUT_PIN PIN_B0
void main()
{
   while(1) {
   output_high(OUTPUT_PIN);
   delay_ms(500);
   output_low(OUTPUT_PIN);
   delay_ms(500);
   
   }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 05, 2010 4:11 pm     Reply with quote

Look closely at your #use delay() statement.

Here is an example program:
http://www.ccsinfo.com/forum/viewtopic.php?t=37215
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Mon Jul 05, 2010 4:30 pm     Reply with quote

Thanks for replying,

I note that initially I had the wrong value and it gave me the 500ms = 5second performance. However I've changed my program and it gave me the OSCCAL errors, I've reset it to 0x00 (centre frequency according to the datasheet) and now it seems I can't send any programs to it.

Is this still applicable to this forum or shall I go to a PIC specific one?

Cheers,
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 05, 2010 5:02 pm     Reply with quote

What's your compiler version ?

Also, you may have the "MCLR disabled with Internal Oscillator" problem:

This thread has a link to a Microchip forum thread on the problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=41261
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