Calcaulating the correct PWM values

Hi there

I need to know if I wrote the correct code for making a PWM signal of 50Hz and a duty cycle of rise time 1.7ms and down time of 18.3ms.

I am using a PIC18f4431 with a 40Mhz crystal

Here is my code:


void main(void)
PTCON0=0b00000100;//Choose a presacalar value of 1:4
PTCON1=0b10000000;//Set the PTEN bit to enable the PWM Time Base
PTPERH=0b00001100;//Set the PWM period to 20ms
int Duty = 800;
int count=0;
PDC0H=0b00000000;//Set the duty cycle to a specific value.
TRISB = 0x00;
//PORTB = 0x00;


Thanks very much


You are reading an archived discussion.

Related Posts

Does anybody use netbeans for C/C++.......i just want to know how and from where did u download the compiler.....i tried it a lot by reading the instructions on the sun...
😕 Hye there, I’m currently trying to design and develop an interactive telephone based remote control and security but I’m having some problems regarding the whole project. I have some...
Hey guys, I read a rumour in the news paper today morning that Arun Sarin (yes 'our own' Arun Sarin who headed Vodafone before retiring this July) has emerged the...
hi, I need to know that how can we measure snr(signal to noise ratio) value with out the help of hardware.i am using ns-2 simulator and i need to measure...
pls help for my project topic in school my discipline is mechanical engineering. thanks