Wednesday, 15 June 2016

Modifying UART clock speed of raspberry pi

 
Before using the UART at GPIO, First it is needed to disable the serial console . Open cmdline.txt file present at /boot directory

sudo /boot/cmdline.txt

This file would have contain following text

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

we need to modify this, modify the content so that it should looks like following


dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

save it with ctrl x then y.

Now we can use UART

To modify the UART clock speed in raspberry pi, config.txt file in boot folder has to be modify .

go to the boot directory and there is a file named as config.txt





open that file in a terminal with sudo nano config.txt

and add the following  line at the bottom

init_uart_clock=64000000


save it by ctrl x then y

reboot the pi sudo reboot


first connect your oscilloscpe probe to pin no 8, it is the tx pin of UART, Set trigger options, channel etc.

Check the speed by sending a character



open terminal and write

echo -n U > /dev/ttyAMA0

you should see a waveform

TO modify UART speed, Write  following in terminal

sudo stty -F/dev/ttyAMA0 230400

you can choose from various UART speed now.


Note that in pi3 the UART is ttyS0 in place of ttyAMA0

No comments:

Post a Comment

Comments System

Disqus Shortname