Sunday, November 17, 2013

Using Raspi Serial Port

Lately I have managed to find some time to dedicate to this project. I am currently working on the Hardware side, will have some pictures of the box I am making soon. I am also starting to do some GUI work using openVG. And just today I connected my AVR board to my Raspi via serial (was using PC before). I will be explaining the details of this last effort in this post.

So I am using the Raspberry Pi serial port to communicate with my AVR board handling all the control I/Os. I will explain here what I did for getting that to work:

The first step was to disable the console output via serial port. To do so, you need to edit the file /etc/inittab and comment out the following line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

And editing /boot/cmdline.txt removing the references to ttyAMA0. This:

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

Should look like this:

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

This info is all coming from here.

Once that is done, since I am working at MIDI speeds, you need the change the the UART clock speed. I added this inside config.txt:

init_uart_clock=2441406
init_uart_baud=38400

And I modified the /boot/cmdline.txt again adding "bcm2708.uart_clock=3000000":

dwc_otg.lpm_enable=0 bcm2708.uart_clock=3000000 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 

Then setting up your UART as 38400 magically makes it be 31250 and MIDI. This is coming from here, here and here.

No comments:

Post a Comment