Originally posted by **stevensarns** September 15, 2023
Hello & thanks in advance for any help. I am having a problem using the RFM69HCW module attached to a ATtiny841. I think the problem is with the SPI library/ATTinyCore. I have successfully used the same code with ATmega328PB and ESP8266 processors. I have narrowed the code down as much as possible to illustrate the issue.
When all code using SPI transfers is commented out, the code works as expected as evidenced by the action on the "scope" pin. However as soon as any SPI action is called, the code hangs; no action on the scope pin and no action on any SPI pin.
I am using ATTinyCore/Konde v1.4.1 and RFM_LowPowerLab v1.5.2 Arduino IDE 1.8.13. The RFM69 module is connected to PA4 to PA6 (SCK, MISO, MOSI, NSS) but not connected for this test (same results if connected).
`
// ATtiny841, chip 841, clock 8MHz internal<4.5V, bootloader UART0
// with optiboot - 71% flash, 66% RAM, requires millis()
// use print(F("xx")) 72% flash, 58% RAM
#include
#include
#define NETWORKID 0 // Must be the same for all nodes
#define MYNODEID 22 // My node ID
#define TONODEID 99 // Destination node ID
#define FREQUENCY RF69_915MHZ // RFM69 frequency
#define scopePin PIN_PB0 // debug
RFM69 radio; // Create a library object
// ----------------------- Setup -------------------------------
void setup() {
Serial.begin(9600); // 115200 works also
pinMode(scopePin, OUTPUT);
delay(200);
Serial.println("Start");
radio.initialize(FREQUENCY, MYNODEID, NETWORKID); // Initialize the RFM69HCW:
// radio.setHighPower(); // Always for RFM69HCW
Serial.println("ok");
}
// ------------------------ Main ----------------------------
void loop() {
scope();
if (radio.receiveDone()) { // incoming msg complete
Serial.print(F("received from ")); // print out the data received
Serial.print(radio.SENDERID, DEC); // from ID
Serial.print(F(", msg [")); // DATA array, DATALEN bytes in size:
for (byte i = 0; i < radio.DATALEN; i++) Serial.print((char)radio.DATA[i]);
Serial.print("], RSSI "); // RSSI smaller stronger
Serial.println(radio.RSSI);
}
}
void scope() {
delay(1);
digitalWrite(scopePin, HIGH);
delay(1);
digitalWrite(scopePin, LOW);
}`
a hang with no action on the SPI pins when we start doing SPI stuff is not good, And the same code is known working elsewhere? (a hang with action on the SPI pins would be less clearcut)
Discussed in https://github.com/SpenceKonde/ATTinyCore/discussions/807