View previous topic :: View next topic |
Author |
Message |
John secada Guest
|
1 second delay |
Posted: Sun May 18, 2008 4:34 am |
|
|
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
|
|
Posted: Sun May 18, 2008 5:38 am |
|
|
Code: |
#use delay(clock=16000000)
|
Without the spaces.
Matro |
|
|
Johnsecada Guest
|
the problem os not solve :( |
Posted: Sun May 18, 2008 8:23 am |
|
|
I remove the spaces but this do not solve the problem ... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 18, 2008 8:41 am |
|
|
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
|
|
Posted: Sun May 18, 2008 9:03 am |
|
|
The problem was in the simulate program ... not in the code ...
10x all for the help |
|
|
|