syamin0712
Member level 1
Hi,
I want to generate continuous 20MHz pulse using function delay_us() in ccs.
I used PIC18F4580 and the crystal was 10MHz with PLL. So that, I can get the clock is 40MHz.
I have this code:
When I compile the code; there is no error. However when I burn into PIC and test using oscilloscope, there was no pulse exist.
Does it correct the way I'm wrote my code?
Because when Im tried let say for 500Hz or 5kHz the code was successfull.
Or does it because of the PIC cannot support for too high frequency?
I want to generate continuous 20MHz pulse using function delay_us() in ccs.
I used PIC18F4580 and the crystal was 10MHz with PLL. So that, I can get the clock is 40MHz.
I have this code:
/// 20MHz pulse
#include <18F4580.h>
#fuses H4,NOWDT,NOLVP,BROWNOUT,PUT,NOPBADEN
#use delay(clock=40000000)
void main ()
{
while (TRUE)
{
output_high(PIN_B1);
delay_us(1/40); //set 25ns each
output_low(PIN_B1);
delay_us(1/40); //set 25ns each
}
}
When I compile the code; there is no error. However when I burn into PIC and test using oscilloscope, there was no pulse exist.
Does it correct the way I'm wrote my code?
Because when Im tried let say for 500Hz or 5kHz the code was successfull.
Or does it because of the PIC cannot support for too high frequency?