derya
Joined: 12 Jan 2005 Posts: 4
|
1MHz pwm signal |
Posted: Wed Jan 12, 2005 7:31 am |
|
|
Hi,
I'm trying to have a 1MHz pwm signal which has a 1/4 duty cycle.
All my effort doesn't work and unfortunatelly I couldn't obtain a signal in this form. Changing duty cycle is not problem, difficulty is obtain a signal which has 1MHz frequency from CCP1 out of controller.
Is it too high?
Highest frequency I could obtain is 6.66 KHz.(T=150 usec). Very far from 1MHz!!! At this situation parameters are as following code.
Is anyone know the way that how can I get this pwm signal?
I'm using PIC18F242 or PIC18F252 and 4MHz external oscillator.
#include "18F242.h"
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
init(){
set_tris_c(0x00);
setup_ccp1(CCP_PWM);
set_pwm1_duty((unsigned int16)(0..to..2^16));
setup_timer_2(4, 150, 1);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
}
main(){
init();
while(1);
} |
|