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 support@ccsinfo.com

delay

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

delay
PostPosted: Wed Feb 16, 2011 1:36 pm     Reply with quote

Hi,

I'm very new to using CCS and in fact this is my first day utilizing it.
I loaded the led flash application but it seems like my delay is 10 times to slow e.g. 100ms delay is giving me in fact a 1second pulse...
I do use a 10MHz crystal (the one that comes on the PIC18 explorer board from Microchip).
I don't understand as I'm not using any kind of prescaler or something.
The code:
Code:

#include <18F8722.h>
#device ICD=TRUE
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES BBSIZ1K                  //1K words Boot Block size
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=10000000)
#define LED PIN_D0
#define DELAY 100


void main()
{

   setup_timer_4(T4_DISABLED,0,1);

    //Example blinking LED program
    while(true){
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
    }

}


Thanks for hints! Rolling Eyes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 16, 2011 1:43 pm     Reply with quote

Quote:
#FUSES LP //Low power osc < 200 khz

#use delay(clock=10000000)

I do use a 10MHz crystal

Look in the PIC data sheet, in the oscillator section, to see the correct
fuse setting for a 10 MHz crystal.
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Feb 16, 2011 1:59 pm     Reply with quote

PCM programmer wrote:
Quote:
#FUSES LP //Low power osc < 200 khz

#use delay(clock=10000000)

I do use a 10MHz crystal

Look in the PIC data sheet, in the oscillator section, to see the correct
fuse setting for a 10 MHz crystal.


Exactly, that did the trick,
Thank you bud, for that hint!
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