@NeverDie said in nRF5 Bluetooth action!:
Whenever I use:
#include <MySensors.h>
on the nRF52832, there is around a 10 second delay between the end of "void startup()" and the beginning of "loop()". Why is that, and what is the MySensors library doing during that interval?
As an alternative, you can define '#define MY_CORE_ONLY' and use ' transportInit(); transportSetAddress(MY_NODE_ID);' to initialize the radio. This dosn't work at the moment with the nRF5. I'm currently looking what the reason is. All radio registers are equal when it's initialized after MySensors normal and my setup(). It's not able to send or receive packages.
Maybe someone has an idea about the reason. Here is my code for nRF5 and other with nRF24.
// Undefine to work in gateway mode
#define MY_CORE_ONLY
#define MY_NODE_ID (0)
// Enable debug
#define MY_DEBUG
#define MY_DEBUG_VERBOSE_RF24
#define MY_DEBUG_VERBOSE_NRF5_ESB
// Enable and select radio type attached
#ifndef ARDUINO_ARCH_NRF5
#define MY_RADIO_NRF24
#else
#define MY_RADIO_NRF5_ESB
#include <nrf.h>
#endif
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_OTA_LOG_SENDER_FEATURE
//#define MY_OTA_LOG_RECEIVER_FEATURE
#ifndef MY_CORE_ONLY
#define MY_GATEWAY_SERIAL
#endif
#include <MySensors.h>
void state() {
#ifdef ARDUINO_ARCH_NRF5
Serial.println("----------------------------------");
Serial.print("NRF_RADIO->STATE ");
Serial.println(NRF_RADIO->STATE, HEX);
Serial.print("NRF_RADIO->EVENTS_READY ");
Serial.println(NRF_RADIO->EVENTS_READY, HEX);
Serial.print("NRF_RADIO->EVENTS_ADDRESS ");
Serial.println(NRF_RADIO->EVENTS_ADDRESS, HEX);
Serial.print("NRF_RADIO->EVENTS_PAYLOAD ");
Serial.println(NRF_RADIO->EVENTS_PAYLOAD, HEX);
Serial.print("NRF_RADIO->EVENTS_END ");
Serial.println(NRF_RADIO->EVENTS_END, HEX);
Serial.print("NRF_RADIO->EVENTS_DISABLED ");
Serial.println(NRF_RADIO->EVENTS_DISABLED, HEX);
Serial.print("NRF_RADIO->EVENTS_DEVMATCH ");
Serial.println(NRF_RADIO->EVENTS_DEVMATCH, HEX);
Serial.print("NRF_RADIO->EVENTS_DEVMISS ");
Serial.println(NRF_RADIO->EVENTS_DEVMISS, HEX);
Serial.print("NRF_RADIO->EVENTS_RSSIEND ");
Serial.println(NRF_RADIO->EVENTS_RSSIEND, HEX);
Serial.print("NRF_RADIO->EVENTS_BCMATCH ");
Serial.println(NRF_RADIO->EVENTS_BCMATCH, HEX);
Serial.print("NRF_RADIO->CRCSTATUS ");
Serial.println(NRF_RADIO->CRCSTATUS, HEX);
Serial.print("NRF_RADIO->RXMATCH ");
Serial.println(NRF_RADIO->RXMATCH, HEX);
Serial.print("NRF_RADIO->RXCRC ");
Serial.println(NRF_RADIO->RXCRC, HEX);
Serial.print("NRF_RADIO->DAI ");
Serial.println(NRF_RADIO->DAI, HEX);
Serial.print("NRF_RADIO->PACKETPTR ");
Serial.println(NRF_RADIO->PACKETPTR, HEX);
Serial.print("NRF_RADIO->FREQUENCY ");
Serial.println(NRF_RADIO->FREQUENCY, HEX);
Serial.print("NRF_RADIO->TXPOWER ");
Serial.println(NRF_RADIO->TXPOWER, HEX);
Serial.print("NRF_RADIO->MODE ");
Serial.println(NRF_RADIO->MODE, HEX);
Serial.print("NRF_RADIO->PCNF0 ");
Serial.println(NRF_RADIO->PCNF0, HEX);
Serial.print("NRF_RADIO->PCNF1 ");
Serial.println(NRF_RADIO->PCNF1, HEX);
Serial.print("NRF_RADIO->BASE0 ");
Serial.println(NRF_RADIO->BASE0, HEX);
Serial.print("NRF_RADIO->BASE1 ");
Serial.println(NRF_RADIO->BASE1, HEX);
Serial.print("NRF_RADIO->PREFIX0 ");
Serial.println(NRF_RADIO->PREFIX0, HEX);
Serial.print("NRF_RADIO->PREFIX1 ");
Serial.println(NRF_RADIO->PREFIX1, HEX);
Serial.print("NRF_RADIO->TXADDRESS ");
Serial.println(NRF_RADIO->TXADDRESS, HEX);
Serial.print("NRF_RADIO->RXADDRESSES ");
Serial.println(NRF_RADIO->RXADDRESSES, HEX);
Serial.print("NRF_RADIO->CRCCNF ");
Serial.println(NRF_RADIO->CRCCNF, HEX);
Serial.print("NRF_RADIO->SHORTS ");
Serial.println(NRF_RADIO->SHORTS, HEX);
Serial.print("NRF5_RADIO_TIMER->MODE ");
Serial.println(NRF5_RADIO_TIMER->MODE);
Serial.print("NRF5_RADIO_TIMER->BITMODE ");
Serial.println(NRF5_RADIO_TIMER->BITMODE);
Serial.print("NRF5_RADIO_TIMER->SHORTS ");
Serial.println(NRF5_RADIO_TIMER->SHORTS);
Serial.print("NRF5_RADIO_TIMER->PRESCALER ");
Serial.println(NRF5_RADIO_TIMER->PRESCALER);
// Reset compare events
#ifdef NRF51
for (uint8_t i=0;i<4;i++) {
#else
for (uint8_t i=0;i<6;i++) {
#endif
Serial.print("NRF5_RADIO_TIMER->EVENTS_COMPARE[");
Serial.print(i);
Serial.print("] ");
Serial.println(NRF5_RADIO_TIMER->EVENTS_COMPARE[i]);
}
Serial.println("----------------------------------");
#endif
}
void setup() {
Serial.begin(115200);
#ifdef MY_CORE_ONLY
transportInit();
delay(1000);
transportSetAddress(MY_NODE_ID);
#endif
}
void loop() {
state();
#ifdef MY_CORE_ONLY
// Check for packages
if (transportAvailable()) {
uint8_t buffer[256];
uint8_t num = transportReceive(&buffer);
for (int i=0;i<num;i++) {
if (buffer[i]<0x10) Serial.print("0");
Serial.print(buffer[i], HEX);
Serial.print(" ");
}
Serial.println();
}
#endif
// Pause
//sleep(1000); don't use this on SAMD. The device must be restored with reset doubleclick
delay(1000);
// Send data
//transportSend(MY_NODE_ID, "abcd", 4, false);
}
@NeverDie said in nRF5 Bluetooth action!:
@d00616 said in nRF5 Bluetooth action!:
P.S.: you can reduce the RX/TX time by enabling fast ramp up in MODECNF0 if you haven't to care about nRF51 compatibility.
Thanks for the tip. I tried it both ways. The first scope capture below is taken without MODECNF0 enabled on bit 0, and the second is with it enabled on bit 0.
Have you checked the MODECNF0 register after ramp up? Maybe the register must be changed in a specific state?