ATtiny412, Konde megaTinyCore, NRF24L01 Bring-up Question

Greetings all,

I am trying to use an Attiny412+NRF24L01 to transmit an incrementing number to an UNO+NRF24L01, after which the UNO displays the numbers in the terminal window. A baby step toward a larger goal. But I can not get it to work.

I verified the UNO receiving side works by using an ATtiny85 + NRF24L01 as the transmitter. (The sketch I was running successfully on the ATtiny85 was a cut and paste of the failing ATtiny412 sketch shown below, but with a few pin assignment changes, and no SPI.h include. )

ATtiny412 Transmitter Sketch (does not work)

//I modified Robin2 "NRF...how-to" post
//with pin changes and no SPI.h this works perfectly on T85 and Uno
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   1
#define CSN_PIN 0  // tried 5, which did not work
int dataToSend = 0;
const byte slaveAddress[5] = {0x52,0x78,0x41,0x41,0x41};

RF24 radio(CE_PIN, CSN_PIN);
void setup() {
    radio.begin();
    radio.setDataRate( RF24_250KBPS ); 
    radio.setRetries(3,5);
    radio.openWritingPipe(slaveAddress);
}
void loop() {
delay(1000);
dataToSend++;
      radio.write( &dataToSend, sizeof(dataToSend) );
}

UNO "receiver" sketch, which works with the ATtiny 85, but not the ATtiny412

//I modified Robin2's sketch from his "NRF... how-to" post
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

int dataReceived;
const byte thisSlaveAddress[5] = {0x52,0x78,0x41,0x41,0x41};

#define CE_PIN   9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

void setup() {
Serial.begin(9600); 
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();   
    pinMode(7, OUTPUT);
}
void loop() {
if ( radio.available() ) {
      radio.read( &dataReceived, sizeof(dataReceived) );
       Serial.println(dataReceived);   
    }

} 

Here's how it's all hooked together.

I determined the above pin assignments using the file
.... megaTinyCore\megaavr\variants\txy2\pins_arduino.h which referred directly to the ATtiny412 and the SPI pins. AVRdude reports a success and the programming rig successfully loads blink.ino.

// ATtiny412 / ARDUINO
//                                     _____
//                             VDD   1|*    |20  GND
//             (DAC) (AIN6) PA6  0   2|     |19  4~  PA3 (AIN3)(SCK)(EXTCLK)
//                   (AIN7) PA7  1   3|     |18  5   PA0 (nRESET/UPDI)
// (MOSI)(TXD*)(SDA) (AIN1) PA1  2   4|_____|17  3   PA2 (AIN2)(MISO)(RXD*)(SCL)

Unusual Compile Message - does this matter?

Multiple libraries were found for "nRF24L01.h"
 Used: C:\Users\Dan\Documents\Arduino\libraries\NRFLite
 Not used: C:\Users\Dan\Documents\Arduino\libraries\RF24

Screen-Shot of the Core/Programming Stuff

As always, your help and comments are greatly appreciated!

BTW, high praise and great appreciation to Dr. Azzy (aka S.Konde) for the tireless work on this platform. BTW_2, I highly recommend Konde's proto boards. I received them earlier in the week, and I couldn't be more pleased.

Thanks,

Dan
San Jose

I'd definitely use the same library on both sides. I don't believe that the NRFLite uses the same default radio settings based on other posts here. I'd use the library manager to remove it, at least temporarily.

To deal with the "multiple libraries" notice without deleting the NRFlite library, I used the full path, directly pointing at the nrf24l01.h file in the RF24 library, in the include. This did not change anything. When I have time I am going to use my old HP logic analyzer/DSO and spectrum analyer to see if I can find clues.

Thanks,
Dan
San Jose

OK. It wasn't so simple.
Anyway, what is the transmitter going to do ? You haven't got many pins left on the MCU for much other activity. I suppose it could send its own battery voltage back to the receiver and, maybe temperature.

Incidentally, a much nicer pinout diagram can be found here without hunting through .h files: megaTinyCore/ATtiny_x12.md at master · SpenceKonde/megaTinyCore · GitHub

Thanks for the graphic!

I got it working.
I spent the day yesterday analyzing the SPI signals and found that the 10mhz SCK frequency was the problem. The tolerance of these Amazon NRF24L01 units maxes out around 10mhz - and on a breadboard with jumpers, it's less. I milled my brain to a fine, worthless powder going through the includes in the RF24 library trying to find a proper software solution, and decided it would be best to simply slow the chip down. Using the the programming settings Konde provided in the Arduino IDE, I slowed the chip by 60% from 20mhz down to 8mhz. This reduced the SCK speed from 10mhz down to, not 4mhz, but to 7.8mhz. Huh? Whatever... I need to get back to other projects.

Interesting Finding: (Inverted MOSI MISO Idle States) The ATtiny85 SPI has the idle state of the MOSI and MISO at 0, where the Hardware SPI in the ATtiny412 has the MOSI and MISO idle state at 1. Seeing this on my scope I sure I was on to something, but I wasn't, the NRF24L01 doesn't care, it only cares about the state of the MOSI and MISO at the rising edge of SCK.

All the best!

Dan