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

How to generate 457 kHz carrier using PIC?

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



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

How to generate 457 kHz carrier using PIC?
PostPosted: Tue Mar 21, 2017 11:44 am     Reply with quote

Is it possible to generate 457 kHz (+/-100Hz) carrier using PIC?
It is better to toggle some pin or to use CCP? But I can't choose right CCP and crystal settings for PIC10 or 12 series.
asmboy



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

View user's profile Send private message AIM Address

PostPosted: Tue Mar 21, 2017 1:36 pm     Reply with quote

what waveform and amplitude are needed?

is modulation part of the picture?
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Mar 21, 2017 1:41 pm     Reply with quote

To get to this sort of frequency, you would have to use a hardware PWM (or something more complex like a COG, but these don't exist on the smallest PIC's).
So you need a chip with a PWM module.
Your crystal frequency would need to be an integer multiple of the frequency you want to generate (/4). So if you used (say) a 7.314272MHz crystal, you could use /16 (4*4) and get an exact frequency.
So a PIC with a PWM (smallest/cheapest say the PIC12F752 or the PIC12F1822).
Code:

SETUP_TIMER_2(T2_DIV_BY_1,3,1);
SETUP_CCP1(CCP_PWM);
SET_PWM1_DUTY(8L);


Once started, the hardware generates this, and the PIC can do anything else you want, but only a very few pins left (2 for power, 2 for crystal, 1 for PWM - only three pins left).
This is for a simple square wave.
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