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

Possible to bitbang a 9600baud UART on nRF51822?

Is it possible to bit bang a 9600 baud UART on the nRF51822 while the BLE softdevice is running?

The reciprocal of 9600 baud is around 100 µs, so the interrupt handler will need to run about that often for the UART to work reliably. However, the S110 SDS specifies that the processor could be taken up by the highest-priority soft device interrupt for up to 400-500 µs.

It seems to me that would prevent the bit-bang timer interrupt from running, and would cause bits to be lost. Is this correct?

I need to communicate with two different devices (so 2 UARTs) using a protocol with 2 stop bits, so I cannot use the chip's hardware UART

  • I was answering thinking that the question is to achieve the max speed that is 9600 baud rate. The method you mentioned will work with a flow control enabled bit banging (for RX to work), but the bit rate achieved will be much less. There is a post for safe attainable baud rate while in connections to be 9600, and this uses hardware UART devzone.nordicsemi.com/.../ I agree with you RK, its doable, but could be tricky. @Brendan Shanks : Could I request you to post your progress in Github github.com/NordicSemiconductor If you succeed, this could prove useful to many.

  • Thanks for the discussion but I also need to receive from both devices and there's no flow control, clearly this can't all be done on the nRF. Current plan is to use another microcontroller as sort of an I/O processor.

  • If that's what you need then regrettably you'll need another chip to help you out. Have you looked at any of the UART/SPI/I2C chips out there? I did a quick google and found some dual UARTs with TX/RX, 64-128 bytes of buffer onboard and a single SPI interface for 5-10 bucks a pop. NXP makes one, Maxim makes one, there's probably others. Unless I already had another component on-board I could use, I'd probably try one of those, should be very easy to interface up.

  • Hi Aryan,

    Using soft device timeslot API to bit bang UART is funny! You will find code in my response from this post :

    devzone.nordicsemi.com/.../

    I only did buffered UART Tx, Tx bytes are buffered and then bit banged using Timer0. After 1 byte transmission, a timeslot extension is queried (querying a new timeslot also works). For timeslot length I added 200µs for processing time to byte transmission duration because I got some SoftDevice errors in soc_radio_timeslot.c l190 . You will find code here :

    github.com/.../AltSoftSerial.cpp

    github.com/.../timeslot.c

  • Hi IOS, good to see that you proved the concept. Can I ask you what type of BLE activity was present at the time of testing UART big banging @9600 baudrate. I am guessing that you should not be using fast connection intervals.

Related