HI,
I've got a custom board with Atmega328PB (the model with two SPI ports) and RFM69HCW.
Is there a way to use SPI1 to communicate with the radio? When I monitor CLK1 using the following code, there is no signal.
I've been looking through the recommended library but can't see where SPI is defined. Not sure if this is relevant, but I'm connecting to my board via ISP (SPI0), not USB.
My code for the TX Based on RFM69 library sample code by Felix Rusu:
#include <RFM69.h>
//#include <SPI.h>
#include <SPI1.h>
#include <avr/io.h>
#include <util/delay.h>
#include <pins_arduino.h>
// Addresses for this node. CHANGE THESE FOR EACH NODE!
#define NETWORKID 0 // Must be the same for all nodes
#define MYNODEID 2 // My node ID
#define TONODEID 1 // Destination node ID
//#define FREQUENCY RF69_433MHZ
#define FREQUENCY RF69_915MHZ
#define ENCRYPT true // Set to "true" to use encryption
#define ENCRYPTKEY "TOPSECRETPASSWRD" // Use the same 16-byte key on all node
#define USEACK true // Request ACKs or not
RFM69 radio;
int val, button;
void setup()
{
DDRB = 0b11111111; // all outputs
DDRC = 0b11111111; // all outputs
DDRD = 0b11110111; // D3 input
DDRE = 0b11111111; // E3 output
radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
radio.setHighPower(); // Always use this for RFM69HCW
if (ENCRYPT)
radio.encrypt(ENCRYPTKEY);
// PORTB = 0b11111111;
// PORTC = 0b11111111;
// PORTD = 0b11111111;
// PORTE = 0b11111111;
}
void loop()
{
static char sendbuffer[62];
static int sendlength = 0;
char input = 'sennnnnd';
val = digitalRead(3);
if(val == 0){
digitalWrite(23,LOW); // E0
delay(100);
digitalWrite(23,HIGH);
delay(100);
}
sendbuffer[sendlength] = input;
if (USEACK)
{
radio.sendWithRetry(TONODEID, sendbuffer, sendlength);
digitalWrite(5,LOW); // E0
delay(100);
digitalWrite(5,HIGH);
delay(100);
}
else // don't use ACK
{
radio.send(TONODEID, sendbuffer, sendlength);
}
sendlength = 0; // reset the packet
}