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

Invert UART

Hello!

In my application, I have to receive UART signals from another device. The problem is the signal comes inverted so the nrf51422 can't handle it. I thought in 2 possibilities: Using external hardware to invert signal (transistor) or do it in software.

Does anyone know if the nrf51422 support UART inversion via software? If not, how can I achieve it?

Another question, but related: I was thinking of sending signals to 1 GPIO and generating the UART interrupt on another pin, just inverting the signal. Can I connect 2 pins together via software?

Thanks in advance

  • your hardware inverter would be easy fix, you can do this in the software but i think it will be lot of overhead and use of lot of modules like PPI, GPIOTE and extra GPIOs to workaround this.

    1. Connect pin with uart sensor data as input to GPIOTE channel 0, configure gpiote channel 0 as event mode and generate an event for every pin toggle.

    2. connect the event (coming out of gpiote channel 0) to PPI to convert that into a task (lets say T1)

    3. configure gpiote channel 1 in task mode with T1 as input, toggle another gpio pin P2(with inital state configured to be opposite of inital state of pin with uart data)

    now you should have inverted data on pin P2, but you cannot use this as input to UART module as this is configured to be output, so you have to connect this pin with another gpio pin and use the latter as input to uart.

    I myself feel this very ugly just to invert the signal. transistor would be just fine for this.

    I thought of using GPIO interrupt handler to do this but then, it would change the timing of the signal.

  • you cannot connect two pins via software if the pin direction is input. But if this is output then it can be done.

Related