Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SX1278 setFrequency() does not work anymore in 7.1.1 #1368

Closed
BBluemer opened this issue Jan 3, 2025 · 4 comments
Closed

SX1278 setFrequency() does not work anymore in 7.1.1 #1368

BBluemer opened this issue Jan 3, 2025 · 4 comments
Assignees
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@BBluemer
Copy link

BBluemer commented Jan 3, 2025

Hello,
with my setup and minimal working example code (see below) the frequency setting of the SX1278 does not work anymore with library version 7.1.1. Using library version 7.1.0 it works as expected.
The Debug output below is identical with both Library Versions.
Thanks for any help.

Debug mode output

Hello World!
SX1278: INIT returns 0
SX1278: TRANSMIT_DIRECT returns 0

Sketch that is causing the module fail

#include <RadioLib.h>

SX1278 radio = new Module(10, 4, 5, 3);
int sx1278_ret = 0;


/*------------------------------------------------------------------------------------------*/
/* setup()                                                                                  */
/*------------------------------------------------------------------------------------------*/
void setup() {

  // System
  Serial.begin(115200);
  delay(500);
  printf("Hello World!\n\r");

  // SX1278 Init
  radio.reset();
  sx1278_ret = radio.beginFSK(450, 19.2, 7.7, 25, 17, 16, false);
  printf("SX1278: INIT returns %d\n\r", sx1278_ret);

  sx1278_ret = radio.transmitDirect();
  printf("SX1278: TRANSMIT_DIRECT returns %d\n\r", sx1278_ret);

}

/*------------------------------------------------------------------------------------------*/
/* loop()                                                                                   */
/*------------------------------------------------------------------------------------------*/
void loop() {
}

Expected behavior

The example code sets the Module to 450.0 MHz and switches the transmitter on. With library version 7.1.0 the spectrum analyzer shows the carrier at 450.0 MHz. Compiling with library version 7.1.1 the carrier is at 434.0 Mhz. Additional setFrequency(450) after initialisation do not help.

Hardware / Software Setup

  • MCU: Teensy 4.1
  • Wireless module type SX1278 (RA-02)
  • Arduino IDE version 2.3.4
  • Library version 7.1.1 or 7.1.0
@CrispyAlice2
Copy link
Contributor

I just encountered this issue as well, it seems like the issue was the module not actually changing the frequency until the LSB frequency register was written. I wrote a quick PR, I'll submit that in a second.

CrispyAlice2 added a commit to CrispyAlice2/RadioLib that referenced this issue Jan 3, 2025
@jgromes
Copy link
Owner

jgromes commented Jan 3, 2025

@CrispyAlice2 I was able to replicate this too - indeed, since 29ede2c register access has been optimized to remove redundant write operations. But if the module is sensitive to change in the LSB frequency register, we will need to figure out a different way. Looking forward to the PR ;)

@jgromes jgromes added the bug Something isn't working label Jan 3, 2025
@jgromes jgromes self-assigned this Jan 3, 2025
@BBluemer
Copy link
Author

BBluemer commented Jan 3, 2025

Gentlemen,

in the mean time i had a deeper look at the manual, at the Register description there is nothing mentioned about a necessary write to the lsb-register to update the whole 3 registers, but on page 82 i found the note: 'The Frf setting is split across 3 bytes. A change in the center frequency will only be taken into account when the least significant byte FrfLsb in RegFrfLsb is written.'

Thank you so much for finding this issue that quick!
Regards, Bert

jgromes pushed a commit that referenced this issue Jan 3, 2025
* Fix frequency issue on SX127x (#1368)

* Add force option to SPIsetRegValue

* Fix indent
@jgromes
Copy link
Owner

jgromes commented Jan 3, 2025

Resolved by merging #1369 - thank you @CrispyAlice2! This bug is quite significant, so I will go ahead and release this as 7.1.2 in the next few days.

Also props to @BBluemer for a clear and concise bug report that allowed to quickly locate and resolve this issue!

@jgromes jgromes closed this as completed Jan 3, 2025
@jgromes jgromes added the resolved Issue was resolved (e.g. bug fixed, or feature implemented) label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

3 participants