PWM setup for PIC16F873A

Status
Not open for further replies.

junhao_wu

Newbie level 3
Joined
Oct 15, 2006
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
Hi Guys! I have just programed my PWM code into PIC16F873A...was wondering if I just connect +5V to VDD, Ground my Vss, I should expect a square wave(PWM) at CCP1 pin?? or do i have to connect some circuity?

below is my C code.

#pragma chip PIC16F873A
#include "math24f.h"
void int_pwm(void)
{
int duty;
CCP1CON = 0;
TMR2 = 0;
TRISC.2 = 0;
PORTC.2 = 0;
PIE1.1 = 0;
PIE1.2 = 0;
PR2 = bin(00111110);
CCP1CON.5 = 0;
CCP1CON.4 = 0;
duty = bin(00011111);
CCPR1L = bin(00011111);
T2CON = bin(00000000);
CCP1CON = bin(00001100);
}
void main(void)
{
int_pwm();
T2CON.2 = 1;
while(1);
}

Pls kindly advise.... thank for inputs
 

hi.
please give me more details to help you better.
 

Hi m.salehi, thanks for helping... I am trying to program a PWM with a period of frequency 16.7KHz, 50% duty cycle, portc CCP1 as output, prescaler of 1:1. Crystal is 4MHz. I have already program the code into the PIC16F873A. Now I wish to test out my PWM output. So what is the setup step??

1) Connect +5V to VDD
2) Connect Vss to ground
3) Using scope to see my PWM waveform with CCP1 pin.

Is that all i need to do see my PWM waveform??

Thanks
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…