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

Generate pwm square wave at 300 khz frequency PIC18F47Q43

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



Joined: 11 Jan 2021
Posts: 7

View user's profile Send private message

Generate pwm square wave at 300 khz frequency PIC18F47Q43
PostPosted: Thu Dec 09, 2021 11:51 pm     Reply with quote

Code:

SETUP_PWM1(PWM_ENABLED | PWM_CLK_FOSC | PWM_CLK_DIV_BY_1);                 
set_pwm1_period(24);                                                       
set_pwm1_duty(1,12); 

This is the code for the pwm generator. This code operates at a frequency of 40 kHz with generation, but not exactly 40 kHz. I want to reach frequencies between 300-320 kHz. But it is impossible to enter the values ​​in float type of course. My microcontroller's pwm is 16 bit. Please help me.
_________________
@electsoftware
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Dec 10, 2021 1:21 am     Reply with quote

Key questions.
What Fosc are you running?. From what source?.
If you just want a square wave, look at the NCO, rather than the PWM.
Gives higher resolution at small division ratios.
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