wolf761
Posts: 3
Joined: Mon Mar 28, 2016 10:29 am
Location: Italy

Raspberry 3B and Serial Port

Mon Mar 28, 2016 11:14 am

Hi, I have installed Raspbian in the new Raspberry 3 and I wanted to connect a GPS module on the serial port.
I went into the Advanced Configuration and I activated the serial port, I have followed this topic ...because I saw that others were similar.

viewtopic.php?f=45&t=49852
I have attached one picture made with the oscilloscope that the GPS module every second transmission occurs...
but in the minicom terminal I do not see anything. I set all the speeds of the port and turned off the flow controls.

I also did a test to disconnect the GPS module and short the pin 8:10 (TX and RX serial port), running minicom to check that the serial port to transmit and receive, but I still do not see anything. As if the port was blocked by something or some not good configuration.

Please indicated a topic where I can verify the operation of the serial port? ... and where can I find the technical specification documents of raspberry 3 b?

Many thanks in advance, Tony
Attachments
SCRN02111.jpg
SCRN02111.jpg (53.82 KiB) Viewed 13882 times

edo1
Posts: 169
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Raspberry 3B and Serial Port

Mon Mar 28, 2016 4:23 pm

which UART are you using?
default is mini-UART now (ttyS0), but you still could use ttyAMA0 as well:
viewtopic.php?t=138223

User avatar
saper_2
Posts: 244
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: Raspberry 3B and Serial Port

Mon Mar 28, 2016 8:41 pm

Yes, but that not fix that you'll get gibberish from serial/uart. Why? Because adding BT (&wifi) forced designers to use uart0 (know so far as ttyAMA0) because it's baud clock generator is independent from core_freq which varies depending on cpu load, temperature and input voltage, also have much bigger hardware buffers (whose are needed for bt...). So they changed GPIO uart0 to uart1. But the issue is that the baud clock generator for uart1 is sourced from core_freq and when core_freq changes the baud rate changes too... (core_freq is adjusted to cpu usage, temperature and voltage). But, fortunately you can lock core_freq :) .

There is issue on github: https://github.com/RPi-Distro/repo/issues/22
And for now only solution (that I found) is to add into /boot/config.txt :

Code: Select all

core_freq=250
Which set the core_freq to 250MHz , but core_freq does not influence cpu_freq.
See yourself:

Code: Select all

pi@pi3:~ $ for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do \
> echo -e "$src:\t$(vcgencmd measure_clock $src)" ; \
> done
arm:    frequency(45)=1200000000
core:   frequency(1)=250000000
h264:   frequency(28)=300000000
isp:    frequency(42)=300000000
v3d:    frequency(43)=300000000
uart:   frequency(22)=48000000
pwm:    frequency(25)=0
emmc:   frequency(47)=250000000
pixel:  frequency(29)=0
vec:    frequency(10)=108000000
hdmi:   frequency(9)=0
dpi:    frequency(4)=0
pi@pi3:~ $
Here you have about vcgencmd: http://elinux.org/RPI_vcgencmd_usage

About temperatures, I've run Pi3 with force_turbo=1 & core_freq=250 in room temperature (about 20-21degC, Pi3 board lay on plastic box and power gps L20 module from 3,3V) I have cpu temperature of 45-48degC with 2 ssh: one running minicom which read data from GPS L20 module , and on 2nd ssh I run test commands...

If you're going to use Pi in non-ventilated case with other components I would suggest do not use force_turbo and cut cpu_freq to 1GHz to lower cpu temperature, but it will depends on your environment.
--
For non-working GDrive links check my git-repo: https://github.com/saper-2/shared-stuff/

wolf761
Posts: 3
Joined: Mon Mar 28, 2016 10:29 am
Location: Italy

Re: Raspberry 3B and Serial Port

Tue Mar 29, 2016 10:06 am

wow, thank you very much
sorry but for me is the first time that I use the Raspberry, I am used assembly with PIC micro and use the serial port is as it should be for all other devices ... once known processor speed for all the devices, including the entire program delay routines etc ... everything works perfectly.
I did not think the thermal drift and the processor load could vary the speed of the port ... however ...
as the first project done with raspberry I wanted to create a watch and connect the GPS module to the serial port without having to go out with the cable to get into a USB port as I am preparing a board that contains the clock chip via SPI, the backup battery, a buzzer, the gps with the connector for an external antenna, etc. ...
Since my first Raspberry is the 3B version, I would like to realize this project in order to get closer to this world, new for me, and since I have installed Raspbian I'd like, use a language like Python 3.
I found tutorials and technical documentation on all versions of Raspberry and little on Raspberry 3 B.

If anyone advise me on how to use or remap any of the existing serial ports on the raspberry 3 B, I would be very happy.

User avatar
saper_2
Posts: 244
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: Raspberry 3B and Serial Port

Tue Mar 29, 2016 4:46 pm

wolf761 wrote:I did not think the thermal drift and the processor load could vary the speed of the port ... however ...
...
I found tutorials and technical documentation on all versions of Raspberry and little on Raspberry 3 B.

If anyone advise me on how to use or remap any of the existing serial ports on the raspberry 3 B, I would be very happy.
About port speed - this is a "bad" design of BCM processor by Broadcom (that's my opinion - like they couldn't source all baud rate generators for each uart from that same clock source...)... Let's summarize this by: "life is not easy" :D
I'm programmer too (Atmel AVRs mostly in gcc :) ), I get the separated clocks idea too, because I've a little experience with STM32 ARM mcu's (and STM8 - those have a very similar hw as mightiest STM32 :) ) - actually your head will hurt when you start reading first time about clock system, buses, etc. in ARMs :D (in comparison to simple pic's or avr's).

RPi3 hardware is almost identical to RPi2, difference might be in ALT functions of some IO pins, Oh, I found ATL functions description: http://elinux.org/RPi_BCM2835_GPIOs

Because the uart1 was made avaiable for masses (and is "inferior" to uart0) it got new dev: /dev/ttyS0 , while /dev/ttyAMA0 is now used for talking to BT...

For programming serial port, use mentioned ttyS0 device, and handle it like any file - that's the beauty of linux all hardware is mapped to filesystem :D... Just look how to use serial port in python on RPi ,and substitute in tutorial ttyAMA0 with ttyS0 - this should do the trick.
I can't help you with python, I've written few scripts in it but nothing hard :) (just something to test some chips on SPI and I2C).

Also, you can use ttyAMA0 as second uart and have it accessible on GPIO header but for this you need to use device-tree overlay - but you won't be able to use BT by doing this. This was discussed on this forum (you have to look for it yourself - I remember seeing it but don't remember where exactly) and there was a solution for this too (DT - device-tree overlay was made too).

--- edit ---

Anyway, I've recorded a short video with power consumption of Pi3 (for other topic) while loading it at best I could :D and I read cpu temp after test (about 15sec since end) I got 55degC so I might heat-up Pi3 cpu to about 65deg while running test :D . Here movie https://youtu.be/E9pZkS7mnq8
--
For non-working GDrive links check my git-repo: https://github.com/saper-2/shared-stuff/

edo1
Posts: 169
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Raspberry 3B and Serial Port

Tue Mar 29, 2016 10:29 pm

saper_2 wrote:Also, you can use ttyAMA0 as second uart and have it accessible on GPIO header but for this you need to use device-tree overlay - but you won't be able to use BT by doing this.
with the new pi3-miniuart-bt overlay, Bluetooth works fine and stable with the Mini UART
viewtopic.php?p=923258#p923258

User avatar
saper_2
Posts: 244
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: Raspberry 3B and Serial Port

Wed Mar 30, 2016 3:03 pm

edo1 wrote:
saper_2 wrote:Also, you can use ttyAMA0 as second uart and have it accessible on GPIO header but for this you need to use device-tree overlay - but you won't be able to use BT by doing this.
with the new pi3-miniuart-bt overlay, Bluetooth works fine and stable with the Mini UART
viewtopic.php?p=923258#p923258
Yes you can switch them - I remember seeing this somewhere... there :D , but I had on my mind that you can get two uarts on GPIO... I looked now at http://elinux.org/RPi_BCM2835_GPIOs if there would be only GPIO41 routed to J8 then we could have 2 uarts...

So yes, edo1 your right, uarts can be only swapped.
--
For non-working GDrive links check my git-repo: https://github.com/saper-2/shared-stuff/

wolf761
Posts: 3
Joined: Mon Mar 28, 2016 10:29 am
Location: Italy

Re: Raspberry 3B and Serial Port

Thu Mar 31, 2016 7:36 am

Hi,

But... if I use /dev/ttyS0 right now I have connected the GPS module to pin 8 and 10 for /dev/ttyAMA0, what should I do? connect the gps module to other pins? If so ... I have to remap them in some way?
I'm sorry if I ask this but it is just to make things right without breaking my head :)

Many thanks, Tony

Electron752
Posts: 142
Joined: Mon Mar 02, 2015 7:09 pm

Re: Raspberry 3B and Serial Port

Thu Mar 31, 2016 12:05 pm

Short Story:
You use exactly the same pins as you did on previous version of the RPI, just modify your applications and scripts to use /dev/ttyS0 instead of /dev/ttyAMA0. Every should just work at that point. :)

Long Story:
Some of the clocks in the RPI 3 are variable but not all independent. The new miniUART has less options, so it may be necessary to fix the speed of some of the clocks. I was consistently getting either garbage or nothing even though everything was correct. So I was told to add this to my config.txt and it worked. Although, I think it has some performance issues.

Code: Select all

force_turbo=0
core_freq=250

User avatar
saper_2
Posts: 244
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: Raspberry 3B and Serial Port

Thu Mar 31, 2016 6:34 pm

Electron752 wrote:Short Story:
You use exactly the same pins as you did on previous version of the RPI, just modify your applications and scripts to use /dev/ttyS0 instead of /dev/ttyAMA0. Every should just work at that point. :)

Long Story:
Some of the clocks in the RPI 3 are variable but not all independent. The new miniUART has less options, so it may be necessary to fix the speed of some of the clocks. I was consistently getting either garbage or nothing even though everything was correct. So I was told to add this to my config.txt and it worked. Although, I think it has some performance issues.

Code: Select all

force_turbo=0
core_freq=250
Yes, exactly, you've 2 options:
1. Use /dev/ttyS0 in place /dev/ttyAMA0 with those same uart pins, just lock core_freq to 250 in /boot/config.txt file. And uart will work fine (up to 115200 baud).
2. Add in config.txt DeviceTree overlay: pi3-miniuart-bt , lock core_freq at 250 , and then use /dev/ttyAMA0 just like on others Pi versions. (For BT setup look on topic from edo1 link).
--
For non-working GDrive links check my git-repo: https://github.com/saper-2/shared-stuff/

chillywillycd
Posts: 20
Joined: Fri Feb 24, 2012 8:34 pm

Re: Raspberry 3B and Serial Port

Sat Apr 02, 2016 9:27 pm

Thanks so much for this discussion!

i'm just trying to do a straight up serial console via usb -> uart/ttl adapter. on my raspi 3b.
all i was getting with a default raspbian installation (jessie from 2016_03_18) was garbage.

adding the following snippet to config.txt (via windows pc) my serial console worked like a charm, just as it has traditionally with other models (pi1B and piZero)

Code: Select all

force_turbo=0
core_freq=250

oodes
Posts: 26
Joined: Thu Mar 10, 2016 3:39 pm

Re: Raspberry 3B and Serial Port

Thu Apr 07, 2016 9:30 am

Electron752 wrote: Long Story:
Some of the clocks in the RPI 3 are variable but not all independent. The new miniUART has less options, so it may be necessary to fix the speed of some of the clocks. I was consistently getting either garbage or nothing even though everything was correct. So I was told to add this to my config.txt and it worked. Although, I think it has some performance issues.
/quote]

I had this exact same issue and discovered the solution from your post so thanks for that. When you say 'may' does that mean not all RPI3 are like this ? Is it just luck of the draw and I'm concerned about
performance issues.
issues if i develop anything further with this pi

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