Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 11th December 2006, 03:44 PM   (permalink)
Default PWM setup for PIC16F873A

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
junhao_wu is offline  
Old 11th December 2006, 07:06 PM   (permalink)
Default

I haven't looked carefully at your code yet, but can't you just simulate it? or does whatever compiler package you're using not allow that? From your code it looks to me like you might be using CC5x, which I've heard will allow simulation from within MPLAB... I would also recommend BoostC to you, which has an IDE and also integrates with MPLAB, either one of which allows you to run simulations before you worry about trying it out on a real PIC.

The PWM module doesn't require any external circuitry to operate, so as long as your code is correct you should see an output...
__________________
EEgeek.net
evandude is offline  
Old 11th December 2006, 08:10 PM   (permalink)
Default

and make sure your setting are good for the osc speed you're using. Same for your config fuses.

i don't know if this software may help you, but anyways...
http://mister-e.org/pages/utilitiespag.html
__________________
Steve
mister_e is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
8bit shift register with latch style setup? bh00 Electronic Projects Design/Ideas/Reviews 15 18th May 2006 05:53 AM
LED transistor matrix setup idea bh00 General Electronics Chat 2 10th May 2006 10:38 AM
back to step 1. i need a first setup DanD Micro Controllers 15 27th April 2006 09:07 AM
my 8051 setup needs an opinion mstechca General Electronics Chat 13 19th April 2006 04:12 PM
What's the most basic setup for tuning pipes? atferrari Electronic Projects Design/Ideas/Reviews 6 30th November 2004 10:05 PM



All times are GMT. The time now is 10:43 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker