This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

No RX on UART

Hi,

I'm using 51822 to control GSM module via UART (57600, no flow control). My device is USB and battery powered. After I program the chip I HAVE to disconnect all the power in order to start system clean and have it working. If I don't completely remove power on start nrf will send commands to GSM module, GSM module will recognize them and send a reply to nrf, but nrf won't get anything on RX (I'm using simple UART without interrupt and without softdevice).

What could it be? I also don't use 32khz xtal, so it synthesises clock from hf crystal.

  • Is there anything on nrf side that I could do to fix that? Can I reset UART somehow to recover from this? If I connect the output to a terminal on PC I dont see any extra data being sent, so i cant say that GSM does something wrong.

    GSM might send a corrupted character when it reboots, but then afterwards it doesnt send anything unless it gets a request from nrf. But nrf seems unable to recover from erroneous state.

  • You can enable the interrupt when this error event occurs, and in the interrupt handler which is triggered by any error, you can recover the uart by

    uint32_t error;
       if(NRF_UART->EVENTS_ERROR !=0)
       {
            NRF_UART->EVENTS_ERROR = 0;
            error = NRF_UART->ERRORSRC;
            NRF_UART->ERRORSRC = error;
       }
    

    This will clear the error and uart is usable again. But if you have not read the RXD byte before GSM sends next character, then overrun error will occur agan. The above proposed way is brute force and does not handle specific errors uniquely, but is better than restarting the chip.

  • Yes thats what I tried to do. The thing is that Im actually trying to actively read UART (using the simple UART method) and I have a timer to prevent hanging. So the timeout is set to 3 seconds, if i dont receive anything in 3 seconds I send a command again to GSM and try to read.

    So you are saying i have to read the RX data, but there is nothing coming out of RX, basically I get stuck on this line:

    while (NRF_UART0->EVENTS_RXDRDY != 1 && !gsmTimeout){};

    I also make sure that GSM module is up and doesnt send anything at all before I clear UART, so it seems like UART cant recover from that problem and I dont understand why.

  • I would like to see the TX and RX on a logic analyzer or some other line sniffer. Without softdevice what you are trying to do is quite basic and it should have worked.

    You said that every 3 seconds the timer expires and if no reply from GSM is received, then nrf sends the command again. Can you please confirm that nrf sends command -> GSM module replies -> nrf does not get reply and times out ->nrf sends command again -> GSM replies.

    If you can confirm this (how are you sniffing the TX and RX lines? can you put an image of it here?) then we know that atleast GSM module is not doing anything wrong and sending data with correct baudrate.

  • Its indeed basic, so probably im doing something really wrong. The sequence that you described is correct. Currently i just have the lines connected to UART-USB interface on the PC, so I just see that nrf sends commands and GSM replies. I can make a picture on oscilloscope as well if that helps.

    Please find photos attached. Measured at the same time from UART USB on PC and on oscilloscope.

Related