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

Choice of timers for different frequencies in #use PWM
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kgng97ccs



Joined: 02 Apr 2022
Posts: 97

View user's profile Send private message

PostPosted: Mon Oct 10, 2022 1:37 am     Reply with quote

CCS has corrected this error (last item in the list below) in v5.110, released on October 1, 2022.

From CCS e-mail:
Code:
A new release of the CCS C compiler for PICmicro(r) microcontrollers has been released. The new version is: 5.110

Recent changes include:
5.110  Many new parts added and some part definitions revised
5.110  Error when using #rom ... = crc16 on some chips is fixed
5.110  Updated PIC18F67K40 family CCP remappable pins to match the current device's data sheet.
5.110  Fixed an issue with missing interrupt defines for some of the PIC18FxxQ84 family.
5.110  Added missing port_b_pullups() function from PIC16F15254 family.
5.110  Fixed an issue with #use pwm() on PIC18F45K22 family with assigning the timer to use.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Oct 10, 2022 1:44 am     Reply with quote

Good.
This is a thing that CCS are good at, and always nice to see a fix arrive. Very Happy
Big question is 'does it work'?....
kgng97ccs



Joined: 02 Apr 2022
Posts: 97

View user's profile Send private message

PostPosted: Tue Jan 17, 2023 9:21 am     Reply with quote

Is it correct that PWM_off(stream) is exactly the same as doing an output_low() to the corresponding MCU pin?
temtronic



Joined: 01 Jul 2010
Posts: 9093
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 17, 2023 10:30 am     Reply with quote

You'd have to cut code to actually see what they're doing.....

PWM_off to me says that the associated pin would be put into Hi-Z mode ( tristated) ,aka neither a zero nor a one...

Maybe 'they' think 'off' should be a zero ? However PWM tend to have 'polarity' option so 'off' could be 'on' !!
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Tue Jan 17, 2023 11:16 am     Reply with quote

I agree with Jay. Turning off the PWM peripheral turns the device off. Does
not drive the pin low. Setting a duty cycle of '0', would drive the pin
low.
kgng97ccs



Joined: 02 Apr 2022
Posts: 97

View user's profile Send private message

PostPosted: Tue Jan 17, 2023 8:37 pm     Reply with quote

Thank you, Temtronic and Ttelmah.

In my code, I use "pwm_on(stream)" to send a "high" PWM signal, and "pwm_off(stream)" to send a "low" PWM signal.

Example:
Code:


pwm_off(stream);
delay_us(562);
pwm_on(stream);
delay_us(562);
pwm_off(stream);   /* end of PWM signals */
output_low(pwm_pin);    /* to reduce current consumption */

Questions:
1. To be sure, is it then that a duty cycle of zero is the same as "output_low(pwm_pin)"?
2. Is it necessary to turn OFF the PWM before issuing an "output_low(pwm_pin)" statement?
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Wed Jan 18, 2023 2:34 am     Reply with quote

1) Yes, and no.
setting the duty to 0 sets the output gate of the PWM peripheral to 0.
This results in the output being 0. However it is not quite the 'same', since
the signal is coming from the peripheral, not the output latch. The _effect_
is the same, but the action inside the chip is not.

2) No. You most definately do not want to turn the peripheral off to
drive like this.
When you use:
pwm_off(stream);
What actually happens is the PWM peripheral enable bit is turned off. The
pin is then driven from what is in the output latch for the bit. Your chip
does not have PPS, so this is the connection that results. The data sheet
shows this in the PWM part by showing that when the enable is turned
off the signal goes to 'port data'. So whether you get high or low, depends
what is in the port latch. Unreliable. Better to just set the output to 0.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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