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

softwareserial on nrf52

We create library for work with software serial, we use two modules gpiote, timer. We have done software serial one instance but we need four (actually just for rx). We don't understand how to solve the problem with bit banging more than just one softwareserial instance. We have some conflicts in timer handlers for different channel but use one timer per one softserial instance is too expensive. Could freertos helps us with that issues?

  • Hi Stas,

    Could you explain a little bit more what is the problem when you mentioned "some conflicts in timer handlers" ?

    Could you provide some more information why you can't use the hardware UART on the nRF52 ? At least it would reduce the number of bit banging UART to 3

  • The problem is we can not manage handler from different instances of one timer simultaneously. We can work only with one softserial uart at a time. When the packets coincide our library is fail. So we wonder could freertos solve this problem. We gonna use hardware uart too of course. We tend to use additional chip stm32f205ret6 it has 6 uart modules 51 GPIO and a lot of other peripherals, on the board we gonna connect it by spi with our main chip nrf52832.

  • How exactly did you implement your soft serial ? My understanding is to use high frequency timer, and use CPU to read the pin on every pulse of the timer, to detect the start bit , stop bit and the data. And on each pulse of the timer the CPU read all 4 pins a the same time, so it doesn't matter if you have 4 UART or more.

    It's mor like a parallel port, but in this case you have only 4 bit, and start bit and stop bit has to be handled.

    But this solution requires the CPU to stay in the timer event handle most of the time. So what you are thinking of using external UART chip maybe a better solution.

  • CPU to read pins only on timer interrupt. All time after interrupt CPU in WFI state.

  • Yes, but I was thinking of high UART baudrate , says 115200bps, the CPU has to wake up every 8us. Also since the 4 UART is not syncronized, you need to sample twice as fast as the clock to make sure you won't miss any pulse. Another limitation is if you have higher priority interrupt (softdevice activity for example) you will miss some bytes on UART.

Related