I was having trouble waking up the DW if it had gone to sleep without setting the wakeup condition bits: DWT_WAKE_WK or DWT_SLP_EN. Under these conditions, the correct way to wake the chip up is to force RSTn low for a short time, and then let it float again.  There are strong exhortations in the manual never to drive RSTn high, so my code had been ultra-conservative. 

I now seem to have the code working reliably.  When unplugging the simple reader test, when it is running invariably locks up the DW chip.   This code seems to unlock it OK, and so far has not failed.  A 1ms delay seems to be enough

#define RESET_DELAY 1  // 1 msnrf_gpio_cfg(          // set the pin up as an output DW_RSTN, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,  // input buffer disconnected NRF_GPIO_PIN_NOPULL, // no internal pullups – high impedence I guess NRF_GPIO_PIN_S0D1, // ‘0’ drives it low with 0.5mA max sink;                                        // a ‘1’ disconnects it NRF_GPIO_PIN_NOSENSE   // not an input so not relevant );
nrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_set(DW_RSTN); // disconnect the pindeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long time
nrf_gpio_cfg( // sets the pin up as an input DW_RSTN, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, // connect the input buffer NRF_GPIO_PIN_NOPULL,         // no pullups ??? NRF_GPIO_PIN_S0S1,  NRF_GPIO_PIN_NOSENSE           // not using GPIOTE, so no used );
nrf_gpio_input_disconnect(DW_RSTN); // disconnect itdeca_sleep(2);

Leave a Reply