CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help With a PWM code for PIC16F690

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
williamcoral



Joined: 08 Feb 2010
Posts: 2

View user's profile Send private message MSN Messenger

Help With a PWM code for PIC16F690
PostPosted: Mon Feb 08, 2010 6:55 pm     Reply with quote

Hi, I have this PWM code for the PIC16F690 but I don't know what is the problem because I make the simulation with Proteus (ISIS) and the output (pins P1B, P1C, and P1D) stay low always.

My CCS compiler vs. is 4.093
PD. I copied the code from another post of "PCM programmer"
Code:

#include <16F690.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)

#define P1A PIN_C5
#define P1B PIN_C4
#define P1C PIN_C3
#define P1D PIN_C2

//===========================================
void main()
{

setup_timer_2(T2_DIV_BY_16, 124, 1);  // 1000 Hz

set_pwm1_duty(31);  // 25% duty cycle
//!
//!// Enable PWM pins P1B, P1C, and P1D for output.
//!// Note:  P1A is done by the compiler.
output_low(P1B);
output_low(P1C);
output_low(P1D);

// Steer the PWM output to all four P1x pins.

setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_A
                       | CCP_PULSE_STEERING_B
                       | CCP_PULSE_STEERING_C
                       | CCP_PULSE_STEERING_D );


while(1);
 


}
williamcoral



Joined: 08 Feb 2010
Posts: 2

View user's profile Send private message MSN Messenger

voila c'est bon
PostPosted: Mon Feb 08, 2010 7:13 pm     Reply with quote

This is the problem with the code, this line of code was placed wrong:
Code:

setup_timer_2(T2_DIV_BY_16, 124, 1);  // 1000 Hz

This is the good code and works fine with Proteus:
Code:

#include <16F690.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)

#define P1A PIN_C5
#define P1B PIN_C4
#define P1C PIN_C3
#define P1D PIN_C2

//===========================================
void main()
{

set_pwm1_duty(31);  // 25% duty cycle
//!
//!// Enable PWM pins P1B, P1C, and P1D for output.
//!// Note:  P1A is done by the compiler.
output_low(P1B);
output_low(P1C);
output_low(P1D);

// Steer the PWM output to all four P1x pins.

setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_A
                       | CCP_PULSE_STEERING_B
                       | CCP_PULSE_STEERING_C
                       | CCP_PULSE_STEERING_D );

setup_timer_2(T2_DIV_BY_16, 124, 1);  // 1000 Hz


while(1);

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 08, 2010 8:21 pm     Reply with quote

It's likely a problem with the Proteus simulator.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group