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

Invert PWM- signal 18f46k80

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



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

Invert PWM- signal 18f46k80
PostPosted: Thu Jan 21, 2021 6:13 am     Reply with quote

Hello all PIC gurus!

I have fast question. Is that chip(18f46k80) any hardware support to invert PWM- signal? Or is it only change to use hardware (transistors,ICs,Etc)?

keypoints in code:
Code:

.
.
setup_timer_2(T2_DIV_BY_16,99,1);
.
.
setup_ccp2(CCP_PWM);         //pin c2
setup_ccp5(CCP_PWM);         //pin b5
.
.
enable_interrupts(GLOBAL);   


WIN7x64
Compiler 5.092

Thank you for your help!
temtronic



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

View user's profile Send private message

PostPosted: Thu Jan 21, 2021 6:30 am     Reply with quote

fast answer
OK, I didin't look ,but
if you take the opposite PWM value, that's 'inversion' ?

say PWM is on 70%, off 30%...inversion would be on 30%,off 70% .
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Thu Jan 21, 2021 7:01 am     Reply with quote

Your chip has two different types of module to generate PWM outputs.
The CCP modules, and an ECCP module.
The CCP does not offer any way to invert the output, except as Jay says
to just reverse the number used. So for a given required duty cycle:

set_pwm1_duty(1023-cycle);

The ECCP module, supports active low or active high outputs, so setup
for a single PWM, and select active low, and you have the inverted signal.

There is only one ECCP module on your chip though.

Remember the ECCP, can simultaneously generate complementary
signals, with a dead band delay between them.
-Terppa-



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

PostPosted: Thu Jan 21, 2021 7:48 am     Reply with quote

Thank you Mr temtronic and Mr Ttelmah

Code:

"say PWM is on 70%, off 30%...inversion would be on 30%,off 70%"

Yes. just like that.

Code:

"just reverse the number used. So for a given required duty cycle:
set_pwm1_duty(1023-cycle);"


This may have only way because i need at least 2- pwm pipe and only one ECCP module.

Thank you guys!
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