cancel
Showing results for 
Search instead for 
Did you mean: 

Can someone explain the function of SX_FREQ_TO_CHANNEL?

AJ_1
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

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.

View solution in original post

7 REPLIES 7
AJ_1
Associate III

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

STTwo-32
ST Employee

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.

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?

 

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.

Hi STTwo-32,

Thanks for the quick reply. Okay, I understand that SX_FREQ_TO_CHANNEL performs the math so you get the correct number to pass to Set_RfFrequency(). I think at this point I'm just trying to understand how the RF-PLL works.

I have 2 follow-up questions:

1. Would you agree it's confusing to have a function called "Set_RfFrequency(Opcode, RfFreq)", where you don't give it the actual RF Frequency? Instead you pass it your desired RF frequency * 1.048576.

2. Since 910,163,968 isn't the actual frequency you transmit at, what is it? Is it a counting value? Does the microcontroller count to 910,163,968 each second and that tells it how quickly to oscillate?

Hello @AJ_1 

Thank you for your interractvity. As you initial question is answered. Please select the post that answer your question as solution and create a new post to give it more visibility on the community so the answer can help you and other users too.

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.

Hi STTwo-32,

Okay, I started a new thread here, feel free to check it out.

Thank you for answering my initial question