UART on my pi cannot send data, I can receive data from another machine, but I cannot send any data using the 'tx' pin of UART. I also try to connect 'tx' and 'rx' on my pi, but still no data is sent or received.
I think it's a software problem, because I tried to burn a fresh image of Raspbean to my SD card, UART works fine. But with my existing system image, it cannot send data. I have made a lot of changes on my current system and want to keep it, but I don't know what I should do to make UART work correctly.
I have followed this blog, and still does not work. http://www.irrational.net/2012/04/19/using-the-raspberry-pis-serial-port/
UPDATE:
I have run gpiotest from here http://abyz.me.uk/rpi/pigpio/examples.html#Shell_code
And the result is good as shown below.
Skipped non-user gpios: 0 1 28 29 30 31
Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Failed user gpios: None
-
Could you download/install pigpio and then run this gpio test.joan– joan2014年11月11日 14:52:09 +00:00Commented Nov 11, 2014 at 14:52
-
Sure. The result is good. I have added results above.LittleBread– LittleBread2014年11月12日 04:19:18 +00:00Commented Nov 12, 2014 at 4:19
-
That shows the gpios can be set high and low and that the internal pull-up/downs are working properly. That means the UART is probably OK. TX is pin 8 (gpio14), RX is pin 10 (gpio15). Can you link the TX/RX. Then stty -F /dev/ttyAMA0 9600 (to set 9600bps). In one window cat </dev/ttyAMA0 (to read UART), in another window ls -R / >/dev/ttyAMA0 (to do a file list).joan– joan2014年11月12日 08:06:45 +00:00Commented Nov 12, 2014 at 8:06
1 Answer 1
I have solved my problem. The reason is that I used gpio14, which is TX, as an input in another script. So it won't send anything, because it'a already configured for other use, and I forget about that.
Thanks
-
1For those who don't know. Each gpio can be in one of eight modes - INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, or ALT5. To work as the UART gpios 14/15 must be in mode ALT0. If you set them as inputs or outputs they will be in the wrong mode and will need to set to mode ALT0 for the UART to work.joan– joan2014年11月12日 13:53:49 +00:00Commented Nov 12, 2014 at 13:53