UART activity detection
Posted: Wed Jun 11, 2025 9:11 pm
Hello,
I want to avoid collisions on my RS-485 bus and not start sending anything if another transmission has already started. On an AVR MCU I can have the UART receive byte interrupt and also have an interrupt handler for level changes on that pin (i.e. going from high to low) as an immediate indicator.
Can I also do that on ESP32? I'm using the normal uart_read_bytes() function and have connected the pins to the UART feature. Can I still add an ISR that handles level changes (i.e. falling edges)? I guess I should use the gpio_isr_register() function to do that, haven't done that before.
Alternatively, I'd also use an interrupt that is triggered only when a UART frame is starting, not on every single level change. If that exists.
I only need to know when somebody else is starting to speak. The communication is normally followed by all nodes on the bus so everyone knows when a message is over and the bus is free again.
If I cannot do that at all on ESP32, I might need to physically connect two pins and use one to receive and the other to monitor. But that's a PCB design change that I'd need to know in advance.
I want to avoid collisions on my RS-485 bus and not start sending anything if another transmission has already started. On an AVR MCU I can have the UART receive byte interrupt and also have an interrupt handler for level changes on that pin (i.e. going from high to low) as an immediate indicator.
Can I also do that on ESP32? I'm using the normal uart_read_bytes() function and have connected the pins to the UART feature. Can I still add an ISR that handles level changes (i.e. falling edges)? I guess I should use the gpio_isr_register() function to do that, haven't done that before.
Alternatively, I'd also use an interrupt that is triggered only when a UART frame is starting, not on every single level change. If that exists.
I only need to know when somebody else is starting to speak. The communication is normally followed by all nodes on the bus so everyone knows when a message is over and the bus is free again.
If I cannot do that at all on ESP32, I might need to physically connect two pins and use one to receive and the other to monitor. But that's a PCB design change that I'd need to know in advance.