cancel
Showing results for 
Search instead for 
Did you mean: 

Do FSK or PSK using HRTIM on STM32G474RE

mala
Associate II

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, 

  • '1' = 45 kHz and '0' = 55 kHz. I want to transmit the message "1010" where each bit is 10µs long (FSK)
  • '1' = 5 kHz and '0' = 10 kHz. Carrier frequency = 400 kHz. I want to transmit the message "1010" where each bit is 10µs long and with an phase shift of 11.5°.

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,

 

3 REPLIES 3
ELABI.1
ST Employee

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:

ELABI1_0-1748430929946.png

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:

ELABI1_1-1748431339521.png

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.

mala
Associate II

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

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.