This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to make the CPU to sleep module by the UART interrupt

Hi, I use the nrf51822 to read the data from the tag which designed by the 24l01p radio module.In the whole progress, first of all, the reading module read the instructions by the PC through the UART. when the instructions are "ON",the 51822 module should start read the tag data, and transmit the data to the PC by the UART.when the instruction is "OFF",the 51822 should enter the low power sleep module.It can't send data but can receive data from the PC by the UART. I wonder to know if I can use the UART interrupt.In the UART part, when the receiver have data, I judge if it is "ON"or"OFF".If it is "ON", I use the _wfe() to make the 51822 start read tag data.However, if it is "OFF",how can I deal with it? can you give me some advice? Thank you!

  • Hi Linda,

    For your application, if you can have the hardware flow control on UART interface, you can use RTS signal from the PC as the wake up source. You can find the example of using RTS as wake up source in app_uart library where we defined the APP_UART_FLOW_CONTROL_LOW_POWER mode. So that the UART RX task can be disabled (and the CPU can be put to sleep mode) and we will wake the chip up when there is a signal on the RTS line.

    In your description, I don't really get it when you mention you "use the _wfe() to make the 51822 start read tag data", could you explain it a little bit more ?

  • Hi, Thank you for your reply. In my application, the nrf51822 read the instunctions from the PC through the UART. If the instruction from the UART is "ON",the 51822 should start read the tag's data which is from the 24l01p.If the instruction from the UART if "OFF".the 51822 is to the low power mode. I don't know how to make the 51822 to wake up by the UART. Is it by the _WFI()?

  • Hi Linda,

    What you described is pretty close to the software flow control mechanism. Currently, you can do that by keeping the UART in RX mode and enabling RXDRDY interrupt so that you will receive RXDRDY event every time there is 1 byte received on the RX buffer. The limitation of this implementation is that the power consumption will remain high (1mA+) when you keep UART in RX mode since this module require 1V2 regulator and 16 MHz clock. This is the reason I recommended the hardware flow control option. So that you can disable UART when waiting for new data and only wake up the CPU and enable UART when there is a pin interrupt (RTS signal)

    Regarding __WFI() instruction, it's the command to put the CPU to sleep waiting for an interrupt. If you want to wake the CPU up, you would need an event/interrupt. You can enable an interrupt by setting the NRF_UART0->INTENSET register and then enable the UART interrupt using NVIC_EnableIRQ()

Related