Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help solving the following problem while using Proteus Simulation

Status
Not open for further replies.

mischa

New Member
Hi there guys. I have access to the Proteus 7 professional package and was using it to try and simulate the pwm generation using the ccp1 module of the pic16f877. I want to gate the RC2 pin so that the pwm appears as an output on it for a while and then disappears. The Pwm is generated and i can see it in the oscilloscope. The problem i am having is that the pwm does not stop or not appear on RC2 even though i set port c as an input. Please take a look at my code and let me know if i am doing something wrong in my code or if its my simulations. I am using c to code in the ccs environment.



#include "16F877.h"
#include "DEFS_877.h"

#include "string.h"
#include <stdlib.h>
#include <stdio.h>

#use delay (clock=7680000)
#fuses HS,NOWDT,PROTECT,NOLVP,BROWNOUT,PUT
//#use rs232(baud=56000,parity=N,xmit=PIN_C6,rcv=PIN_C7)

void squarewave (void);
void pwmgenerated (void);

unsigned int a,i;

port_b_pullups(TRUE); // when no signal output of b is low
set_tris_d(0x00); //setting port d as output

void main (void)
{
a=0;
while(1)
{

if (a==0)
{
pwmgenerated();
delay_ms(15);
}
set_tris_c(0xFF); //set port c as input...now the pwm will not be visible on RC1. This does not work in the simulations! I even triedthis: set_pwm1_duty(0)
}
}


//this function generates a 120khz pwm
void pwmgenerated (void)
{

setup_timer_2(T2_DIV_BY_1,15,1); //ENABLES TIMER2,pR2=15, PRESCALAR=1
setup_ccp1(CCP_PWM); //enable Pwm mode
set_pwm1_duty(8); //sets 50% DC
a=1;
}



 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top