pete-theobald
Posts: 4
Joined: Sun Aug 26, 2012 2:40 pm

UART not transmitting data (solved)

Sun Aug 26, 2012 2:50 pm

Hi Everyone,

I'm completely stumped by a problem with my raspberrypi board and hoping someone can help. I have a board connected to the gpio header, the board has a pic which sends a message which the pi receives. I've checked this with a screen session connected to ttyAMA0. I've tried to transmit characters back to the pic but they aren't received. I investigated a bit further and it looks like the pi isn't sending the characters in the first place. I connected a scope to the TXD pin on the GPIO and then use a python script to send messages as follows

Code: Select all

import serial
serialPort = serial.Serial("/dev/ttyAMA0", 9600, timeout=0.5, rtscts=False, dsrdtr=False, xonxoff=False,bytesize=serial.EIGHTBITS,parity=serial.PARITY_NONE)
while True:
    serialPort.write("Hello world!")
    serialPort.flush()
Theres no signal coming from the tXD pin at all. When I send data to the pi frmo the pic, it receives it fine so I don't think I have the pins the wrong way round. That also shows that I have the right pin as I have gnd, TXD and RXD in a row (Also no signal on any pin).

Is there any chance i've blown up the uart? I have the data passing through an isolator with the pi side run off the 3.3v pin of the GIPO so very unlikely.

Regards
Pete

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: UART not transmitting data

Sun Aug 26, 2012 3:25 pm

Have you disabled the kernel log output on /dev/ttyAMA0 ?
Remove "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" from /boot/cmdline.txt

Also you need to comment out the second line below at the bottom of /etc/inittab
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Also, have you tried looping the pi back to itself by connecting the TxD and RxD together ? Then you can run a terminal program like minicom (you may need to install this first) and see if the typed characters are received and displayed.


HTH
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

pete-theobald
Posts: 4
Joined: Sun Aug 26, 2012 2:40 pm

Re: UART not transmitting data

Sun Aug 26, 2012 3:35 pm

Thanks for the reminder!
I had already commented out the line in inittab and removed it from cmdline.txt but thats exactly what I was trying to check.
Its started working now which is strange. I was checking the wrong pins with the scope but that doesnt explain why it didnt show up when I tested every pin in turn (probably a gnd error as I had the pins on the wrong row).
Now I need to work out why my pic won't receive any characters...
Pete

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: UART not transmitting data

Sun Aug 26, 2012 7:05 pm

What Baud are you using ? and does the pic code use ints ?
Batteries not included, Some assembly required.

pete-theobald
Posts: 4
Joined: Sun Aug 26, 2012 2:40 pm

Re: UART not transmitting data

Sun Aug 26, 2012 11:15 pm

DexOS wrote:What Baud are you using ? and does the pic code use ints ?
I managed to receive characters earlier but not reliably. 115200 baud. The pic is running freertos so I have a wrapper around the uart to stop any clashes between threads. I can handle single chars but it drops lines if I try and put chars back into lines. That's tomorrow's job to fix though! Receive code is using an interrupt but it pushes chars into a freertos queue which is read from a thread.
Pete

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: UART not transmitting data

Mon Aug 27, 2012 1:49 pm

From my experience, it sounds like a baud rate problem.
Have you tried a lower rate ?.
Batteries not included, Some assembly required.

pete-theobald
Posts: 4
Joined: Sun Aug 26, 2012 2:40 pm

Re: UART not transmitting data

Mon Aug 27, 2012 7:46 pm

It was much simpler than that, I had a small solder bridge between the TX and another pin so a soldering iron and some copper braid sorted it out. The pics a QFN package and they're a real pain to solder!!! Its working at 115200 again now.
Pete

Return to “Interfacing (DSI, CSI, I2C, etc.)”