HARIS RASHID
Newbie level 4
i want complete code which generate 1 and 5 hz pwm from pic 18f4520 or any other pic using micro c.kindly help me urgently.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// 1Hz PWM ( and 5Hz PWM with the changes indicated in comments )
void main() {
char duty;
int mils;
int maxmils;
int n;
LATC = 0;
TRISC = 0;
duty=50; // enter percent duty cycle here
mils=duty*10; // comment out this line for 5Hz PWM
maxmils=(100-duty)*10; // comment out this line for 5Hz PWM
// mils=duty*2; // comment in this line for 5Hz PWM
// maxmils=(100-duty)*2 // comment in this line for 5Hz PWM
while(1){
LATC=1;
for(n=0;n<mils;n++){
Delay_ms(1);
}
LATC=0;
for(n=mils;n<maxmils;n++){
Delay_ms(1);
}
}
}