Page 1 of 2

UART2 Rx data problem

Posted: Fri Nov 26, 2021 3:05 pm
by lucibel
hi,
I'm using ESP32 TTGO Display to receive data from $PortA.26 with UART2 then transfer these data to Computer with UART1 (Tx $PortA.1, Rx $portA.3).
Problem is that UART2 received data are always 255 ! but as you cans see below, the signal to $PortA.26 is not always 255.
OSC.jpg
OSC.jpg (156.89 KiB) Viewed 3271 times
So I made a test with and without data input
- When data wire disconnected from $PortA.26 , input data = 0 see below
- when data wire connected from $PortA.26 , input data = 255 see below
data.jpg
data.jpg (65.43 KiB) Viewed 3271 times
Data on screen
screen.jpg
screen.jpg (33.85 KiB) Viewed 3267 times

I don't know what's wrong, please check.

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 3:07 pm
by lucibel
sorry can not add the files to first post
Data disp.fcsx
(30.82 KiB) Downloaded 111 times
Data disp.fcsx
(30.82 KiB) Downloaded 111 times
Seb

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 3:24 pm
by BenR
Hi Seb,

Please can you try this slightly modified program. This should interrupt on every byte received and add each byte to the circuilar buffer one at a time. Before I beleive you were trying to do a bit too much inside the interrupt.

When we have at least 4 bytes in the buffer we re-send them to the PC and display on the LCD.
Data_Send2.fcfx
(27.23 KiB) Downloaded 104 times
I'm not sure on the data you're working with but you can use the CB component to do things like wait until you get a specific character and then go from there allowing you to sync up correctly with the data you're receiving and throw any surplus data away.

Let us know how you get on.

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 3:43 pm
by lucibel
Thx Ben for your prompt reply, I just test it and the result is NG.
Panic.jpg
Panic.jpg (65.6 KiB) Viewed 3258 times
FYI, the data are from a sensor who is pushing 16 bytes every each second (1hz)
The first and second bytes to receive are always Byte0=0X42 and Bytes01=0x4D
For example,: 42 4D 0C 51 09 A2 07 2B 01 35 05 81 20 08 20 AD

66:77 received are ok --> 0x42 0x4D

Seb

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 4:28 pm
by BenR
Hi Seb,

Looks like you're getting some data through now.

What about this instead?
Data_Send2.fcfx
(21.92 KiB) Downloaded 106 times
This waits for the first two bytes to be received, throwing anything else away. Once the bytes are received it waits for the buffer to fill with a complete reading of 14 data bytes. Once this happens it transfers everything through to the PC and prints out the first four data values on the LCD.

Watchdog delay reset was caused by the lack of delay in your main loop so I've put this back in now.

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 4:40 pm
by BenR
Sorry missed the ':' characters in between the numbers.
Data_Send2.fcfx
(22.45 KiB) Downloaded 107 times

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 4:48 pm
by lucibel
Im testing,
what do you mean by " CB component" when you said "you can use the CB component to do things like wait until you get a specific character" ?

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 6:12 pm
by lucibel
Thx a lot Ben it works very well !!!! :D :D :D
may be I will need your help to send data to sensor next week.

What is "CB component" ?

BIG THANKS

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 7:40 pm
by medelec35
lucibel wrote:
Fri Nov 26, 2021 6:12 pm
What is "CB component
It's the Circular Buffer component.
It's very useful if receiving a fair bit of comms data.

Re: UART2 Rx data problem

Posted: Fri Nov 26, 2021 11:00 pm
by lucibel
Okay, understood now, yes very useful
Thx Martin