Skip to main content
Associate III
March 17, 2024
Solved

Can someone explain the function of SX_FREQ_TO_CHANNEL?

  • March 17, 2024
  • 2 replies
  • 2244 views

Hello,

I'm working on an application that uses the NUCLEO-WL55JC development board. I was looking in the SubGHz_Phy_PingPong example code, and I noticed a macro called SX_FREQ_TO_CHANNEL. To use this macro, it seems you input the carrier wave frequency you want to transmit at, and it converts it to the value you pass as an array of 8-bit numbers to HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_RFFREQUENCY, array, arr_len).

So if I want to transmit at 868 MHz, I give that value to SX_FREQ_TO_CHANNEL, which outputs 910,163,968. But why is SX_FREQ_TO_CHANNEL needed at all? Why can't I pass 868,000,000 directly in the RADIO_SET_RFFREQUENCY packet?

I think it has something to do with the RF-PLL frequency, but I don't understand. Can someone help explain why RADIO_SET_RFFREQUENCY doesn't actually set RF-PLL to frequency included in the packet?

Thanks in advance.

Best answer by STTwo-32

Hello @AJ_1 

The SX_FREQ_TO_CHANNEL(chan, frequency) take the frequency (in MHZ) and calculate the RfFreq that will be addeed to the Set_RfFrequency() command:

STTwo32_0-1713546830543.png

Refer to the chapter 5 of the RM0453 for more details.

STTwo-32

2 replies

AJ_1Author
Associate III
March 21, 2024

Is it possible it has to do with how the microcontroller was designed? I'm still confused on this.

STTwo-32
STTwo-32Best answer
Technical Moderator
April 17, 2024

Hello @AJ_1 

The SX_FREQ_TO_CHANNEL(chan, frequency) take the frequency (in MHZ) and calculate the RfFreq that will be addeed to the Set_RfFrequency() command:

STTwo32_0-1713546830543.png

Refer to the chapter 5 of the RM0453 for more details.

STTwo-32

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.
AJ_1Author
Associate III
April 19, 2024

Hi STTwo-32,

I figured the macro was used because it efficiently does the calculation, but I still don't understand why we need to convert the number at all.

Let me ask my question a different way: when I want to transmit at 868 MHz, why am I calling the RADIO_SET_FREQUENCY command and giving it 910,163,968? I don't want the center frequency at 910 MHz, I want it at 868 MHz. If I called the RADIO_SET_FREQUENCY command and gave it 868,000,000, what would my center frequency be then?

 

STTwo-32
Technical Moderator
April 19, 2024

Hello @AJ_1 

I've just updated my comment. The new version should have give more data.

Best Regards.

STTwo-32

 

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.