View previous topic :: View next topic |
Author |
Message |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
How to generate 457 kHz carrier using PIC? |
Posted: Tue Mar 21, 2017 11:44 am |
|
|
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
|
|
Posted: Tue Mar 21, 2017 1:36 pm |
|
|
what waveform and amplitude are needed?
is modulation part of the picture? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Mar 21, 2017 1:41 pm |
|
|
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. |
|
|
|