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

Error in all examples! #122

Open
frspp opened this issue Apr 6, 2023 · 1 comment
Open

Error in all examples! #122

frspp opened this issue Apr 6, 2023 · 1 comment

Comments

@frspp
Copy link

frspp commented Apr 6, 2023

One need first define the settings and only after that try getCC1101(), not the other way around. Examples does not work because they have it the wrong way around around.

Correct way:

void setup() {
  Serial.begin(9600);

  ELECHOUSE_cc1101.setSpiPin(18, 19, 23, 17); // Must be BEFORE Init()!
  ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
  ELECHOUSE_cc1101.setGDO0(32); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
  ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
  ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
  ELECHOUSE_cc1101.setMHZ(433.9); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
  ELECHOUSE_cc1101.setSyncMode(0);  // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
  ELECHOUSE_cc1101.setCrc(1);      // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.

  if (ELECHOUSE_cc1101.getCC1101()) { // Check the CC1101 Spi connection.
    Serial.println("CC1101: Connection ok.");
  } 
  else {
    Serial.println("CC1101: Connection error!");
  }

  Serial.println("CC1101: Rx mode started.");
}
@frspp frspp changed the title FYI: error in example "cc1101_receive_minimal" FYI: Error in all examples Apr 6, 2023
@frspp frspp changed the title FYI: Error in all examples Error in all examples! Apr 6, 2023
@angrest
Copy link

angrest commented Dec 30, 2023

This does not help when using "GD-free" communication.
gettCC1101() just reads register 0x31 (CC1101_VERSION according to the header file).
When a chip is connected, this returns for me the value 0x04, without chip, returns 0xFF - The library checks for a value >0, so this is probably the problem. I'd guess reading from a non-existing register on SPI will just return something with all bits set. The result is independent from whether or not I initialize the chip first.
Thus, the function should better read

bool ELECHOUSE_CC1101::getCC1101(void) {
	setSpi();
// Assuming only Version 4 is around...
	if (SpiReadStatus(CC1101_VERSION) == 0x04) {
		return 1;
	} else {
		return 0;
	}
}

This check is not very elaborate and could be true for many SPI devices, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants