Hello all,
I am trying to make a new bootloader where the CSN and CE pins are connected to pin 7 and 8. (CSN = 7 and CE = 8 ).
This is what I changed in the bootloader:
// SPI communication
#define SPI_DDR DDRB
#define SPI_PORT PORTB
#define SPI_PORT2 PORTD
#define SPI_PIN PINB
#define SPI_SCLK 5 // Arduino Pin 13 <-> Bit 5 of port B
#define SPI_MISO 4 // Arduino Pin 12 <-> Bit 4 of port B
#define SPI_MOSI 3 // Arduino Pin 11 <-> Bit 3 of port B
#define SPI_CSN 7 // Arduino Pin 7 <-> Bit 7 of port D
//#define SPI_CSN 2 // Arduino Pin 10 <-> Bit 2 of port B
#define SPI_CE 0 // Arduino Pin 8 <-> Bit 0 of port B
//#define SPI_CE 1 // Arduino Pin 9 <-> Bit 1 of port B
#define CE_PULSE_LENGTH 20 // IMPORTANT: minimum CE pulse width 10us, see nRF24L01 specs. Set 20us to be on the safe side
#define csnlow() DDRD &= ~_BV(SPI_CSN)
#define csnhigh() DDRD |= _BV(SPI_CSN)
#define celow() SPI_PORT &= ~_BV(SPI_CE)
#define cehigh() SPI_PORT |= _BV(SPI_CE)
static void SPIinit() {
// set pin mode: MOSI,SCLK,CE = OUTPUT, MISO = INPUT
SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(SPI_CE) | ~_BV(SPI_MISO);
// Set CSN = output
DDRD = _BV(SPI_CSN);
}
I uploaded the firmware to an Arduino and want to connect it to another Arduino which is programmed with the Serial Gateway sketch.
For discovery of nodes I use the MYSController software on windows, this is working correctly as I can discover my temperature node (which is programmed via arduino with the normal arduino bootloader).
But I can't get it to work, am I missing something?
I checked the settings in MyConfig (channel, power etc) but these are the same on the serial gateway sketch and the bootloader.
Compiler output for bootloader:
"C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc" -x c -mno-interrupts -funsigned-char -funsigned-bitfields -DF_CPU=16000000L -Os -fno-inline-small-functions -fno-split-wide-types -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -Wall -mmcu=atmega328p -c -std=gnu99 -MD -MP -MF "MYSBootloader.d" -MT"MYSBootloader.d" -MT"MYSBootloader.o" -I../libraries/MySensors MYSB
ootloader.c -o MYSBootloader.o
In file included from MYSBootloader.c:44:0:
MYSBootloader.h:28:2: warning: no semicolon at end of struct or union [enabled by default]
};
^
In file included from MYSBootloaderRF24.h:4:0,
from MYSBootloader.h:13,
from MYSBootloader.c:44:
MYSBootloaderHW.h:96:13: warning: 'uart_init' defined but not used [-Wunused-function]
static void uart_init() {
^
MYSBootloaderHW.h:126:13: warning: 'put_int' defined but not used [-Wunused-function]
static void put_int(uint8_t i) {
^
"C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc" -nostartfiles -Wl,-s -Wl,-static -Wl,-Map=".map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mrelax -Wl,-section-start=.text=0x7800 -mmcu=atmega328p -o MYSBootloader.elf MYSBootloader.o -lm
"C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-objcopy" -O ihex -R .eeprom MYSBootloader.elf MYSBootloader.hex
"C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-size" MYSBootloader.elf
text data bss dec hex filename
2004 2 214 2220 8ac MYSBootloader.elf
Thanks for reading!