Hello, I have a need to use 9 bit communications with the ESP32. 1 start bit, one stop bit, and 9 data bits.
ESP32 supports up to 8 data bits, but it is possible to use a parity bit to send data.
To send, we can reconfigure the parity "polarity" prior to sending each byte, in order to control if it is one or zero. We may also be able to just manually enter the parity bit into registers, but I haven't looked into that yet.
In the technical reference manual, it sounds like we might be able to just receive data with a bad parity, and read it anyways, then figure out what the parity is. If the UART hardware doesn't let you read data that came with a bad parity, there seems to be the option to read data bit by bit as it comes in and manually transfer each bit to storage.
Does anyone know if the first method for receiving 9 bit data would work? It doesn't seem to say, since it's using the parity bit in a way it isn't meant for. I don't have a development board so can't try it out.
Also would anyone happen to know off the top of their head if the coprocessor is connected to the UART? Because doing things bit by bit would take up a measurable amount of processing time. It'd be like bitbanging, except using the UART hardware for timing and all that.
9 Bit UART
Re: 9 Bit UART
Hi!
I came across this problem and couldn't find anything.
But, I forked the SoftwareSerial library for the ESP32 and modified it a bit so 9 bit frames work.
Here you go!
https://github.com/ionini/espsoftwareserial
Hope someone finds this useful.
I came across this problem and couldn't find anything.
But, I forked the SoftwareSerial library for the ESP32 and modified it a bit so 9 bit frames work.
Here you go!
https://github.com/ionini/espsoftwareserial
Hope someone finds this useful.
-
- Posts: 6
- Joined: Fri May 15, 2020 12:48 pm
Re: 9 Bit UART
I have tried your library with an ESP32 board compiled on Arduino IDE, but I get an error.ionini wrote: ↑Tue Oct 29, 2019 1:43 amHi!
I came across this problem and couldn't find anything.
But, I forked the SoftwareSerial library for the ESP32 and modified it a bit so 9 bit frames work.
Here you go!
https://github.com/ionini/espsoftwareserial
Hope someone finds this useful.
Hereafter the feedback from compile:
Hope that you can help me,
Pierre
D:\Pierre\Documents\Arduino\libraries\espsoftwareserial-master\src\SoftwareSerial.cpp: In member function 'void SoftwareSerial::enableRx(bool)':
D:\Pierre\Documents\Arduino\libraries\espsoftwareserial-master\src\SoftwareSerial.cpp:140 error: invalid conversion from 'void (*)()' to 'void (*)(void*)' [-fpermissive]
attachInterruptArg(digitalPinToInterrupt(m_rxPin), (void (*)())(rxBitISR), this, CHANGE);
^
In file included from C:\Users\peter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/esp32-hal.h:53:0,
from C:\Users\peter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:35,
from D:\Pierre\Documents\Arduino\libraries\espsoftwareserial-master\src\circular_queue/circular_queue.h:24,
from D:\Pierre\Documents\Arduino\libraries\espsoftwareserial-master\src\SoftwareSerial.h:27,
from D:\Pierre\Documents\Arduino\libraries\espsoftwareserial-master\src\SoftwareSerial.cpp:23:
C:\Users\peter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/esp32-hal-gpio.h:82:6: note: initializing argument 2 of 'void attachInterruptArg(uint8_t, void (*)(void*), void*, int)'
void attachInterruptArg(uint8_t pin, void (*)(void*), void * arg, int mode);
^
exit status 1
Erreur de compilation pour la carte ESP32 Wrover Module
-
- Posts: 5
- Joined: Fri Apr 15, 2022 7:18 am
Re: 9 Bit UART
Hello Guys,
I have some problem. I use 9 bit for this ,i should software uart.Can you help me and can you share an example with me.
I have some problem. I use 9 bit for this ,i should software uart.Can you help me and can you share an example with me.
Re: 9 Bit UART
if this is the only problem, then I took the code from a similar library, edit the SoftwareSerial.cpp file, the function void SoftwareSerial::enableRx(bool on), change the line to
Code: Select all
attachInterruptArg(digitalPinToInterrupt(m_rxPin), (void (*)())(rxBitISR) , this, CHANGE);
Code: Select all
attachInterruptArg(digitalPinToInterrupt(m_rxPin), reinterpret_cast<void (*)(void*)>(rxBitISR), this, CHANGE);
Who is online
Users browsing this forum: Baidu [Spider], markkuk and 75 guests