Can someone explain the function of SX_FREQ_TO_CHANNEL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-17 10:25 AM
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.
Solved! Go to Solution.
- Labels:
-
LoRa
-
STM32WL series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-17 10:46 AM - edited ‎2024-04-19 10:15 AM
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:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-20 08:36 PM
Is it possible it has to do with how the microcontroller was designed? I'm still confused on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-17 10:46 AM - edited ‎2024-04-19 10:15 AM
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:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-19 10:17 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-19 10:22 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-19 11:26 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-19 11:43 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-19 12:06 PM
Hi STTwo-32,
Okay, I started a new thread here, feel free to check it out.
Thank you for answering my initial question