I need to create a virtual uart port on a stm32 microcontroller. The pins are given and can be changed to timer input channels. The recieving signal is going to be modulated in current and voltage and i need to detect both. Those two pins can not be assigned to a uart. Does somebody has a tutorial or something, that can lead me in the right direction? I just started programming microcontrollers and i am still strugeling with all the timer, interrupts and details stuff.
0
votes
If you just started with microcontroller programming, creating a virtual "bit-banged" UART is not a good project, as it is a rather advanced task. Start by writing code that uses the available UART hardware instead. Also, are you sure that this isn't actually a hardware task? As in, how to translate the current modulated signal to voltage modulated "TTL" levels?
- Lundin
That being said, this question is far too broad for SO. Also please note that questions asking where to find tutorials or other off-site resources are off-topic here.
- Lundin
Generally, I don't understand how will be modulated with voltage and current. How you UART input signal suppose to look like?
- tilz0R
Your question is unclear. Please describe this modulated signal in detail and what kind of STM32 controller do you have (full part number).
- Bence Kaulics
1 Answers
1
votes
If we are talking aobut baudrates for small (9600), then you can achieve this with timer and EXTI. On EXTI set pin to rising and falling edge and between each IRQs check timer value.
If value is greater than start and stop condition time, you failed, else you have to check time spent for EXTi and calculate whether you received 10101010 or 11001100 or any other combination.
For TX mode, use timer for precise interrupts at bit slice for UART output data and create state machine for data output bit by bit.
Another option is to use SPI as virtual UART.