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

1 second delay

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







1 second delay
PostPosted: Sun May 18, 2008 4:34 am     Reply with quote

Hello

I want to reach delay 1 second by using delay_ms(1000)
I know that it would not be exact 1 second and the processor would be occupied with the counting but it is good for my needs

The pic controller has CRYSTAL with 16 MHZ frequency and i use this code:


#include <16f88.h>
// #use delay(clock=20000000)
#use delay(clock=16 000 000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

void main(){

//set_tris_a(00000000b);
set_tris_b(0x00);
set_tris_a(0x00);

while(1){
output_b(0xFF);
delay_ms(500);
output_b(0x00);
delay_ms(500);
}

I cant reach 1 second with this code ... please tell me where is my error ?
Matro
Guest







PostPosted: Sun May 18, 2008 5:38 am     Reply with quote

Code:

#use delay(clock=16000000)

Without the spaces.

Matro
Johnsecada
Guest







the problem os not solve :(
PostPosted: Sun May 18, 2008 8:23 am     Reply with quote

I remove the spaces but this do not solve the problem ...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 18, 2008 8:41 am     Reply with quote

Try this program. It will blink an LED on pin B0. It uses the internal
oscillator instead of the external crystal. Try it, exactly as shown below.
Code:

#include <16F88.H>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)

void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}
Johnsecada
Guest







PostPosted: Sun May 18, 2008 9:03 am     Reply with quote

The problem was in the simulate program ... not in the code ...
10x all for the help
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