2025-05-20 7:22 AM - last edited on 2025-06-04 4:33 AM by mƎALLEm
Hello everyone,
I'm trying to do FSK and PSK modulation using HRTIM in STM32G474RE but I have what I want when I use Oscillo to display.
For example,
How can I do this ?
If someone can help me or have an another solution using nucleo ST board. Do not hesitate to suggest me please.
Best regards,
2025-05-28 4:27 AM
Hi @mala,
There are many possible solutions, such as the chopper feature, but below is the simplest one: Since FSK needs to modulate PWM frequency for both mark ('1') and space ('0') with different frequencies, you will need to adjust this frequency each bit period, in this case, 10 µs. Therefore, you will need two timers: one for PWM generation and another for bit timing. When the bit timer expires, you will modify the PWM timer to match the bit frequency.
This is the configuration for Timer B, which is used to handle the bit timing of 10 µs, leading to 100 kHz. The interrupt is enabled at the timer reset:
This interruption should be used to modify the second timer period, Timer A, in order to handle a new PWM frequency as shown in the screenshot below:
This timer is used for PWM, with 55khz frequency, and half mode for PWM generation, so modifying the period will keep a 50% duty cycle, at Timer B interrupt routine, SW/User should modify the period of this timer, to decide about the frequency, 45khz to generate bit1, 55khz as configured initially to generate bit0.
I hope this can help you.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-06-03 1:47 AM
Hello @ELABI.1 ,
Thank you for your responses, but now I could you tell me, where or how to bind these two Timers ? for the synchronization? And about the output, I want only one output. this will be on Timer A so?
Please, if this is possible I would like to have the full configuration of these Timers and others examples.
Thanks
2025-06-04 1:38 AM
Hi @mala,
In the initial request, I didn't understand why bits 1 and 0 have different frequencies but the same duration = 10 µs.
I need more information to provide an accurate configuration and better understand your intent. It would be helpful if you could provide more details, such as the duration (in µs) of the mark (bit 1) and the space (bit 0), as well as the frequency of the carrier...
You will find attached a project with a Timer unit and a waveform. The `main.c` file contains the method that allows modifying the frequencies when the expected bit duration is reached (a multiple of the carrier duration, see the `HAL_HRTIM_CounterResetCallback` function in `main.c`). Please note that this is only an example and doesn't exactly match your request, but this configuration will also help you create your own setup.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.