Hello
I am quite a beginner and have been trying to get it work for 2 weeks now.
I would like to merge these 2 example codes from nordic:
- Shockburst TX example
- Registry retention timers on
I got reg retention to work, but the transmissioon does not go through. Can anyone help me with the working code where these 2 codes are combined...
I paste both of them here below:
1) Shock burst TX example:
#include "nrf24le1.h" #include "hal_clk.h" #include "hal_rtc.h"
static bool volatile radio_busy;
void main(void) { uint8_t payload[3];
while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M) {
}
RFCKEN = 1U; RF = 1U; EA = 1U; hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
for(;;) { payload[0] = ~P0; hal_nrf_write_tx_payload(payload, 3U); CE_PULSE(); radio_busy = true; while (radio_busy) { } } }
NRF_ISR() { uint8_t irq_flags;
irq_flags = hal_nrf_get_clear_irq_flags();
switch(irq_flags) { case (1 << (uint8_t)HAL_NRF_TX_DS): radio_busy = false; break; case (1 << (uint8_t)HAL_NRF_MAX_RT): hal_nrf_flush_tx(); radio_busy = false; break; default: break; } }
2) Registry retention timers on
void mcu_init(void) { P0CON = 0x70; // Disable digital input buffer, pin used for 32kHz. P0CON = 0x71; // Disable digital input buffer, pin used for 32kHz.
P0DIR = 0x03; // Two pins used for 32 kHz XO. P1DIR = 0x00; P2DIR = 0x00; P3DIR = 0x00;
P0 = 0x00; P1 = 0x00; P2 = 0x00; P3 = 0x00; }
void wakeup_tick() interrupt INTERRUPT_TICK { P02 = !P02; }
void main(void) { mcu_init();
hal_rtc_start(false); hal_clklf_set_source(HAL_CLKLF_XOSC32K); hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0); hal_rtc_set_compare_value(0x7FFF); hal_rtc_start(true);
// Wait for the 32kHz to startup (change phase) while((CLKLFCTRL&0x80)==0x80); while((CLKLFCTRL&0x80)!=0x80);
IEN1 = 0x20; EA = 1;
while(1) { // Register retention mode PWRDWN = 0x04; // Standby mode (wait for interrupt) PWRDWN = 0x07; // Clear PWRDWN PWRDWN = 0x00; // Continue to run code P03 = !P03; }; }