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

UARTE - START BIT INTERRUPT - documentatation question

Hi

I have been using nRF52 in my project. I am not using provided uart drivers for one uart -> UARTE1. I am using DMA access and I have no problem to send and record messages from multiple devices on this channel (connected to different pins so I am talking with only one perypherial at time) when nRF starts communication.

Right now one of devices can (can but don't have to) give a response without nRF starting communication. I know with when it will happen but the length of response is unknown and exact time is also unknown.

Right now I just prepare device for the message:
  NRF_UARTE1->RXD.MAXCNT = message_rx_size;
  NRF_UARTE1->RXD.PTR = (uint32_t)&message_rx[0];
  NRF_UARTE1->TASKS_STARTRX = 1;

and after some time I just close receiving.
  NRF_UARTE1->TASKS_STOPRX = 1;

And my implementation has two potential problems.

1st I am starting reciving in an arbitrary moment, since I dont know can I check for a flag that we have some interrupt (list of avaliable events is below). Which event indicate new transmission comming? (Of cours I will need to enable this interrup in INTEN and INTENSET registers)

2nd. I stop after some time. I don't know if I will have 1b, 25b or 512b of data. Is there a good solution to check if there is nothing more comming? I know that if the data will be comming, all data will be at once. If delay between 2 characters will be above some threshold (e.g. 10ms) then it is not a part of the message and I dont want to record this.

Looking for a hint!

Pawel

Parents
  • Hi, typically your problems can be handled by init the RAM buffer with zeros before STARTRX, and then you can at any time just check the RAM location to manually see how many bytes (if any) have been updated since STARTRX. A cleaner approach may be to hook the RXRDY event using PPI to start a timer or use as a counter for the timer, thereby you can use the RXRDY event to either start a timer that timeout or to count the number of received bytes.

  • Hi,

    thanks for the answear.

    I am using almost exactly the same approach you mentioned. Clearing RAM buffer and have timeout for the loop (simple iteration counter since we are using timers already and we don't care of ISR since they are very short.

    As I understand my 2nd question regarding different new data cannot be resolved since I dont know if incomings 1's are inside message or there is nothing new. OK that should be not a problem.

    I am little concerned about my 1st question:

    Does nRF52 have an event if a start condition on it's RX line is detected?

Reply
  • Hi,

    thanks for the answear.

    I am using almost exactly the same approach you mentioned. Clearing RAM buffer and have timeout for the loop (simple iteration counter since we are using timers already and we don't care of ISR since they are very short.

    As I understand my 2nd question regarding different new data cannot be resolved since I dont know if incomings 1's are inside message or there is nothing new. OK that should be not a problem.

    I am little concerned about my 1st question:

    Does nRF52 have an event if a start condition on it's RX line is detected?

Children
  • > Does nRF52 have an event if a start condition on it's RX line is detected?

    Sorry no, only an RXDRDY event when an entire byte is received.

    Not sure what you want to do here, but it may be possible to disable UART, setup RXD as a normal GPIO input with wakeup/interrupt on low level, and then immediately enable UART receive if pin go low, however you likely will loose the first byte this way. I guess you can also use flow control instead.

  • Thanks a lot.

    Unfortunetly the device I am communicating with may have a delayed response, so it maight occure that it will start sending response (or any information) and if I will be unlucky (with thousends of devices and thousends of tries at least few times I will be) while I will start transmiting to it and the communication will fail.

    Thanks a lot I will need to change a hardware to use flow control if this is a must in my application.

Related