stm32f407 discovery board as a 100MHz FM transmitter using crystal feedback trick

Hi All,
     It's been a long time I haven't updated my blog coz it is hard to get some free time.  Anyways, I have a small hack to share now.

This is a very simple hack, the aim of this project is to transmit a song stored in STM32F407 flash memory over air by FM at 100MHz. At first you can have a look at the below video, a weird demo taken through my mobile phone. A fixed song is repeatedly transmitted from the stm32f407 discovery and it received on a mobile phone FM radio which is tuned at 100MHz.


How it works?

 A song + voice in wav format is saved in the flash memory from an offset after application code.
The *.wav can be directly dumped into the flash say from address 0x08005000 after renaming the file as *.bin.  This can be done directly by using ST-LINK utility in windows.

Now a small application code is written which starts at 0x08000000 which will read the song file at location 0x08005000 and throws the bytes to a PWM pin. This is done repeatedly in an infinite loop by a timer interrupt which is configured according to the sampling rate of song+voice wav. It can be done by DMA as well.

Now one more thing, the system clock is derived from 8MHz external crystal oscillator. Using the internal PLL, the system clock is set to 100MHz. Now the Master Clock Output option is enabled to toggle a pin (PA8) at 100MHz. So the carrier frequency for FM is ready!

Now if we run the code, the PWM pin (PE9) will get the song data in a pulse width modulated format. An RC filter is connected to this pin to demodulate it and thus we will get a decent analog song signal. If we connect a earphone or an amplifier over here, we should be able to hear the song.

 Fine, now how to transmit the song over air?

"Crystal feedback hack"

The trick over here is to disturb the crystal oscillator according to the song data. For this a 22K resistor is connected from the analog song signal to one of the crystal PIN. This setup will load the crystal circuitry according to the instantaneous amplitude of song signal. The frequency of the crystal is getting affected by this. In simple words, frequency modulation is happening over here. The song data is getting modulated over 8MHz.

We already set the MCO pin to toggle at 100MHz. Since the 100MHz is generated from the 8MHz crystal clock, the modulation will be observed in the 100MHz signal also (obviously magnified). The feedback resistor 22K is selected in such a way that it won't affect the working of the crystal circuitry and won't do over modulation. We can play with these values later.


Sorry, need to connect an antenna on pin PA8 to transmit the signal properly over air.
For time being, I connected a small female jumper wire which was more than enough for the demo.

Yes, now it is done. :)

I am getting range of around 30 meters with this simple 20 cm wire antenna. If we connect a proper quarter wave length wire/telescopic antenna, the range may increase beyond 100meters as well.

(In below photo you can see a 22K resistor connected from RC filter output to crystal pin.
That is the only external hardware modification for FM modulation)

RC filter:
 R = 100 ohms
 C = 0.1 uF

Feedback resistor:
  R = 22K. (Remove R24 and short those contacts and connect feedback resistor from filter output to R24 pin as in the above photo)

The same experiment can be done by connecting an SD card and can transmit the song over the air the same way...... May be we can use helix mp3 decoder to play mp3 files from sd card and can do the same crystal feedback hack...

Thanks to ST for providing a nice GUI tool called stm32CubeMX which generates the initialization code for clock, MCO settings, timer settings etc. This makes the development process much easier and no need to dig into the datasheet to configure the registers.

Source Code: 

Hex file with audio:

  Try it under your own risk.
 This project is for educational purposes only and is not intended to interfere with any radio channels in restricted/commercial bands. Neither site nor I, am liable for careless actions. Please check for the legality before attempting the project within your area. Since the GPIO toggling is not sinusoidal, higher harmonics will be there in the transmitted signal, so be careful while trying it out as it can transmit harmonics in restricted band.


  1. Cool hack! I wonder if we can hack this up into a super cheap RF transmitter/receiver:D

    1. This will not be cheap coz MCU is expensive, also the audio quality will not be that good compared to a proper FM transmitter. This is just a hack for fun, thats all :)

    2. true, unless we use the STM32f030 and transmit at 48MHz frequency. I was thinking of transmitting data instead of audio to another STM32F030 MCU. the receiver circuit might be too much of a hassle though. haha. :D

  2. Hi can you tell me the fuse settings for the atmega16 voice echo.Thsnks..
    Is it

  3. The RMS value(Root Square Mean value=> output from the speaker.) is 35 watts for every satellites. 130 watts may be the RMS value for subwoofer. Hence total of approximately 200 watts RMS for the entire system. Frequency fact is 35 HZ to twenty,000HZ. Seem pressure level more than 103 decibels.

    Just how much experience have you got? For those who have experience dealing with vehicle wiring before you've got a best begin. If you're a novice you might like to only allow the pros handle it or at best educate yourself. Also, how knowledgeable are you currently of the vehicle particularly? Even though the common procedure will probably be generally exactly the same, there are several different steps you might want to take with respect to the type of your automobile, so take individuals into account.
    Now it's been observed the more the pattern of seeing lots of automobiles on the highway the greater may be the in-vehicle entertainment sought after. An increasing trend is viewed of favoring an in-vehicle entertainment from the vehicle audio system. There might be many factors with this new liking, possibly to savor yourself to maintain your nagging children busy having a cartoon film. But even to utilize these technology you have to what fundamental car audio electronics your automobile needs.

    Car Electronics: Sync Your Vehicle to another Generation. In the past, cars were only for transportation and a few even possessed cars to mirror their social status. Nowadays, almost every other person is the owner of a vehicle. It's not only a transportation help where you need to have it and achieve your destination inside a short drive. Cars have grown to be a part of the existence. With todays traffic, hrs are put in the automobile to achieve the destination. Almost everyone has their breakfast within the vehicle in order to their office.

    B I-amplifiers: They offer different electricity increases for treble and bass amounts. B I-amplification may be needed when individual treble and bass audio system are set up.
    The car stereo receiver may be the electronic utilized in the vehicle externally. Her functionality from the Bluetooth and in addition it props up hands-free calling. This digital camera makes it super easy to speak within the vehicle without holding the telephone. The Bluetooth connection provides the facility of speaking hands-free. This can help because it reduces the likelihood of distraction and disastrous occasions. The vehicle package music gamers are utilized within the vehicle which assists the playing of tunes within the mp3 and mp4 format formats. Additionally, it includes the modulator, earphones within the vehicle. This facility makes it simple to savor the background music with no type of disturbance. The Television and films may also be loved within the vehicle.

    When you purchase a vehicle, lots of attention has been compensated towards the make of the vehicle, the make, the colour, the upholstery and so forth. It's as vital to take serious notice from the car stereo systems by every other Car accessories and electronics.... You can't just easily fit in any audio system within the vehicle. To locate about systems for that cars, go through.

  4. Hy I tried replicating your project.
    I get sound going to crystal (checked with speaker) but on output pin PA8 I get only currier 100MHz without modulation. I do not have oscilloscope to check but on my radio when I start STM32 I get a change from static to silent. I believe it is emitting only 100MHz currier without modulation. Can Someone help?
    I rechecked everything and it is all connected like you did it.
    In summary 22k resistor is connected to R24 witch is shorted.R25 is left as is because it already a short. capacitor is connected to GND and 100R resistor is connected to PE9. Also have antenna like you. Have I missed something?

    1. Let me check and will get back to you soon..

    2. I made some photos of how I connected it and schematics.