cancel
Showing results for 
Search instead for 
Did you mean: 

MYIR MYD-YA157C Board - Repeated Data on UART Receive

medex
Associate II

Description: I'm working with the MYIR MYD-YA157C board, based on the STM32MP157C, and experiencing an issue with UART data reception. When receiving data via UART, the same 10-byte buffer is repeated multiple times (50-60 times) instead of getting fresh data. I verified the setup using a TTL converter and can confirm that the data stream appears as expected when monitored directly, so the problem seems to be specific to the board.

I've attached my program below. Any insights or solutions to receive fresh data on each read would be appreciated.

Code Example:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <string.h>

volatile unsigned char Data[10];

int UART_Receive() {
int uart_rxfilestream = -1;
struct termios options;

uart_rxfilestream = open("/dev/ttySTM4", O_RDWR | O_NOCTTY); // Adjust to your UART device

if (uart_rxfilestream == -1) {
perror("Unable to open UART");
}

// Configure UART
tcgetattr(uart_rxfilestream, &options);
options.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
tcflush(uart_rxfilestream, TCIFLUSH);
tcsetattr(uart_rxfilestream, TCSANOW, &options);

int rx_length = read(uart_rxfilestream, Data, sizeof(Data));

if (rx_length < 0) {
perror("UART RX error");
} else if (rx_length == 0) {
perror("No data available.\n");
} else {
for (int i = 0; i < 10; i++) {
printf("%d\n", Data[i]);
}
}
close(uart_rxfilestream);
return 0;
}

int main() {
while(1) {
UART_Receive();
}
return 0;
}


Steps I've Taken:

  1. Verified data integrity with a TTL converter; the data appears as expected.
  2. Ensured the UART port (/dev/ttySTM4) configuration on the board.

 

Question: What could be causing the repeated data issue, and how can I modify the code or UART setup to receive fresh data for each read operation? Could this be related to buffer handling, or might additional UART configuration steps be needed? Any guidance is welcome.



0 REPLIES 0