2023-02-06 11:27 AM
I need to be able to read an external sensor whose status should be interpreted as received communication. This will either be an analog signal that needs to be processed via an ADC or an external I2C ADC - the result of which needs to be further processed to determine if it represents a high or low value.
Is there a way of passing this information directly to the UART via software - or do I need to control a GPIO pin and connect it to the RX pin of the UART?
2023-02-06 11:46 AM
Its not totally clear to me what you want to achieve. The UART receive data register (USART_RDR) is read-only on most (all?) STM32, so you cannot write a char to it.
2023-02-06 12:03 PM
I started to answer...and now I'm pausing to re-think.
I'm not directly communicating between a pair of UART's. I'm going to be connecting to off-board devices that operate a higher voltages (30VDC or more) and while the MCU will transmit via pulsing the voltage via relay (see my other question you already answered) the remote responses are via current pulses. Which I will need to detect via a current sensor - and then I further need to compare those current values against other factors to decide if they represent data that counts as "received".
So now I'm wondering - do I do all that processing and then trigger a GPIO output that is wired back to the UART RX, or do I just process the information directly? I would need to trigger the GPIO at the baud rate the RX is configured for, not a big deal, but as I'm writing this it feels like using the UART RX for this is an unecessary complication. Using the TX function makes sense...but am I gaining anything by using the UART RX? Hmm..
2023-02-06 12:21 PM
If the incoming signal bits need processing in the MCU, I wouldn't sent them out to an UART but put the bits together to entire bytes or messages in software. Using an UART requires good adherence to a baud rate and doesn't give you much additional benefits.
hth
KnarfB