View previous topic :: View next topic |
Author |
Message |
kgng97ccs
Joined: 02 Apr 2022 Posts: 97
|
|
Posted: Mon Oct 10, 2022 1:37 am |
|
|
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: 19540
|
|
Posted: Mon Oct 10, 2022 1:44 am |
|
|
Good.
This is a thing that CCS are good at, and always nice to see a fix arrive.
Big question is 'does it work'?.... |
|
|
kgng97ccs
Joined: 02 Apr 2022 Posts: 97
|
|
Posted: Tue Jan 17, 2023 9:21 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Jan 17, 2023 10:30 am |
|
|
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: 19540
|
|
Posted: Tue Jan 17, 2023 11:16 am |
|
|
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
|
|
Posted: Tue Jan 17, 2023 8:37 pm |
|
|
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: 19540
|
|
Posted: Wed Jan 18, 2023 2:34 am |
|
|
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. |
|
|
|