Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM simulation on Proteus

Status
Not open for further replies.

shalfan

Newbie level 1
Joined
Nov 25, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
0
Hi,

I’m new to the world of MCUs and to this forum so I’m sorry ahead for any silly mistakes I make, please be gentle with me.

I’m trying to use PIC16F88 to convert analog data from 2 channels, manipulate it and generate PWM signal through RB3/CCP1.

I’m using CCSC 4.093 and PROTEUS ISIS 7.5 SP3 as simulator.

I managed to use the ADC and to manipulate the data but I’m stuck with the PWM output. It just won’t produce the signal. I tried to follow the strait forward examples on CCSC help file and it still didn’t work.

It seems that the problem is with the set_pwm1_duty() function or the setup_timer_2() function. When I write set_pwm1_duty() before setup_timer_2(), it works and I get PWM signal, but when I switch places between them (as the example in CCSC help files) it doesn’t work. I tried to debug it and it seems that the value in CCPR1L does not move into CCPR1H when TM2 equals PR2. By the way now I tried to debug it using MPLAB SIM and it work fine!! But it won’t work with ISIS. Any suggestions?

This is just an example of the code that doesn’t work (if I move the set_pwm_duty() before the the setup_timer_2() it works fine):

#include <16F88.h>
#include <math.h>
#fuses HS,NOWDT,CCPB3
#use delay(clock=20000000)
#use fast_io (A)
#use fast_io (B)

void main()
{
int i=0b00111111;
Set_tris_a(0xff);
Output_b(0);
Set_tris_b(0);

//**** PWM Init****//

setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_1,0b11111111, 1);

//****************//

While( True )
{
delay_us(100);
i+=1;
set_pwm1_duty(i);
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top