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.
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 on screen
I don't know what's wrong, please check.
UART2 Rx data problem
-
- Posts: 172
- http://meble-kuchenne.info.pl
- Joined: Thu Sep 23, 2021 3:44 pm
- Location: France
- Has thanked: 29 times
- Been thanked: 22 times
UART2 Rx data problem
Last edited by lucibel on Fri Nov 26, 2021 3:13 pm, edited 4 times in total.
Seb
-
- Posts: 172
- Joined: Thu Sep 23, 2021 3:44 pm
- Location: France
- Has thanked: 29 times
- Been thanked: 22 times
Re: UART2 Rx data problem
sorry can not add the files to first post
Seb- Attachments
-
- Data_Send2.fcfx
- (28.63 KiB) Downloaded 103 times
Seb
-
- Matrix Staff
- Posts: 1747
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 444 times
- Been thanked: 604 times
Re: UART2 Rx data problem
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.
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.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 172
- Joined: Thu Sep 23, 2021 3:44 pm
- Location: France
- Has thanked: 29 times
- Been thanked: 22 times
Re: UART2 Rx data problem
Thx Ben for your prompt reply, I just test it and the result is NG.
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
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
Seb
-
- Matrix Staff
- Posts: 1747
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 444 times
- Been thanked: 604 times
Re: UART2 Rx data problem
Hi Seb,
Looks like you're getting some data through now.
What about this instead?
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.
Looks like you're getting some data through now.
What about this instead?
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1747
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 444 times
- Been thanked: 604 times
Re: UART2 Rx data problem
Sorry missed the ':' characters in between the numbers.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 172
- Joined: Thu Sep 23, 2021 3:44 pm
- Location: France
- Has thanked: 29 times
- Been thanked: 22 times
Re: UART2 Rx data problem
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" ?
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" ?
Seb
-
- Matrix Staff
- Posts: 1457
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 513 times
- Been thanked: 473 times
Re: UART2 Rx data problem
Martin