Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Interfacing (DSI, CSI, I2C, etc.) • UART0 with Tx on GPIO14 problems

$
0
0
hello,

i have problems to send data over the uart0 on GPIO14 Tx
i hope someone can see what is wrong :D i am trying things now for the whole day :x
but i don't see it.
i am checking the data on a logic analyzer.

it is not working with the code a made also not with the shell comand.
so to test some things a give a command in the shell that send 1 byte: 0x55
but i see random values on the logic analyzer (every now and then it's OK), with the shell comand and also withe code i made.
the settings of the LA are correct, i check that with a other device who is sending serial data.
the code that i used in the shell:

Code:

printf '\x55' > /dev/serial0
in: sudo nano /boot/firmware/config.txt
i add on the bottem of the file:

Code:

[all]enable_uart=1dtoverlay=disable-btdtparam=uart0=on
i made a minimal code but that is al so not working:

Code:

#include <stdio.h>#include <fcntl.h>#include <unistd.h>#include <termios.h>int main() {    int fd = open("/dev/serial0", O_WRONLY | O_NOCTTY);    if (fd < 0) {        perror("open");        return 1;    }    struct termios tty;    if (tcgetattr(fd, &tty) != 0) {        perror("tcgetattr");        return 1;    }    // Set baud rate    cfsetospeed(&tty, B9600);    cfsetispeed(&tty, B9600);    // 8 bits, no parity, 1 stop bit    tty.c_cflag &= ~PARENB; // no parity    tty.c_cflag &= ~CSTOPB; // 1 stop bit    tty.c_cflag &= ~CSIZE;    tty.c_cflag |= CS8;     // 8 bits    //tty.c_cflag &= ~CRTSCTS; // no flow control    tty.c_cflag |= CLOCAL | CREAD; // enable receiver, ignore modem lines    tty.c_lflag = 0;  // raw mode    tty.c_iflag = 0;  // raw input    tty.c_oflag = 0;  // raw output    tcflush(fd, TCIOFLUSH);    if (tcsetattr(fd, TCSANOW, &tty) != 0) {        perror("tcsetattr");        return 1;    }    unsigned char data = 0x55;    if (write(fd, &data, 1) != 1) {        perror("write");        return 1;    }    close(fd);    return 0;}

Statistics: Posted by trixo — Sun Jan 11, 2026 1:17 pm — Replies 7 — Views 96



Viewing all articles
Browse latest Browse all 7503

Trending Articles