3

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
3
  • Could you download/install pigpio and then run this gpio test. Commented Nov 11, 2014 at 14:52
  • Sure. The result is good. I have added results above. Commented 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). Commented Nov 12, 2014 at 8:06

1 Answer 1

2

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

answered Nov 12, 2014 at 11:43
1
  • 1
    For 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. Commented Nov 12, 2014 at 13:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.