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 CCS Technical Support

problem PWM

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



Joined: 03 Jun 2015
Posts: 2

View user's profile Send private message

problem PWM
PostPosted: Wed Jun 03, 2015 9:07 am     Reply with quote

Hello, I have a problem with the function:

#use PWM

It doesn't work (i have no signal).

I work with the PIC 16f1459 and I have the version 5.007

My program is:
Code:

#include <16F1459.h>
#device ADC=10
#Fuses INTRC_IO
#use delay(clock=8MHZ)
#use i2c(master, SCL=PIN_C1, SDA=PIN_C0)
#use PWM (OUTPUT=PIN_C5, TIMER=2, FREQUENCY=10kHz)

void main()
   {
   pwm_on();

   pwm_set_frequency(10000);

   pwm_set_duty_percent(500);

   while (true);
   }
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jun 03, 2015 12:15 pm     Reply with quote

what does the .LST file show for your code ??

or if you use PIN_C5?
Ttelmah



Joined: 11 Mar 2010
Posts: 19549

View user's profile Send private message

PostPosted: Wed Jun 03, 2015 12:42 pm     Reply with quote

I can confirm that the problem is the old compiler is not setting the PWM1CON bits. 5.010, which is the oldest I have kept also does not.
So:
Code:

#include <16F1459.h>
#device ADC=10
#Fuses INTRC_IO
#use delay(clock=8MHZ)
#use i2c(master, SCL=PIN_C1, SDA=PIN_C0)
#use PWM (PWM1,OUTPUT=PIN_C5, TIMER=2, FREQUENCY=10kHz,STREAM=P1)
//tell it to use PWM1
#byte PWM1CON=getenv("SFR:PWM1CON")
//PWM1CON register

void main()
{
   pwm_on(P1);
   pwm_set_frequency(P1,10000);
   pwm_set_duty_percent(P1,500);
   PWM1CON=-0xC0; //enable output

   while (true)
     ;
}


Appears to set everything up correctly...

Understand that 5.007, was _beta_ at best.
Damien



Joined: 03 Jun 2015
Posts: 2

View user's profile Send private message

PostPosted: Thu Jun 04, 2015 9:08 am     Reply with quote

Thank you.
It don't work, i see the "watch" and PWM1CON=0xE0

not 0xC0 ...

I have a signal but it is a pulse inverse with approximately 100Hz and low signal 10us length and high signal approximately 10ms length.
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