How do I change the SPI clock (P9_22) speed on BBB? And what is the maximum speed?

1,728 views
Skip to first unread message

Ardit Cuka

unread,
Jul 15, 2014, 4:38:30 PM7/15/14
to beagl...@googlegroups.com
Maybe this might be a simple thing, but i have searched and could'nt get nowhere.
Thanks

John Syn

unread,
Jul 15, 2014, 5:11:40 PM7/15/14
to beagl...@googlegroups.com

From: Ardit Cuka <ardi...@gmail.com>
Reply-To: "beagl...@googlegroups.com" <beagl...@googlegroups.com>
Date: Tuesday, July 15, 2014 at 1:38 PM
To: "beagl...@googlegroups.com" <beagl...@googlegroups.com>
Subject: [beagleboard] How do I change the SPI clock (P9_22) speed on BBB? And what is the maximum speed?

Maybe this might be a simple thing, but i have searched and could'nt get nowhere.
Thanks
This is set in the device tree. In the Linux Kernel source for BBB look in /arch/arm/boot/dts/am335x-bone-common.dtsi

Regards,
John

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ardit Cuka

unread,
Jul 16, 2014, 11:21:02 AM7/16/14
to beagl...@googlegroups.com
I just need a code in python that sets that frequency to what i want!

ky...@cranehome.info

unread,
Jul 17, 2014, 2:36:15 PM7/17/14
to beagl...@googlegroups.com
It's set in device tree at boot time.   I don't think you are going to find a way to change that on the fly with a running system.  

Ardit Cuka

unread,
Jul 17, 2014, 2:56:58 PM7/17/14
to beagl...@googlegroups.com
I don't need to change to clock speed when the system its running. I want to change it before and then run the system.
Using somthing like this:
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P9_22", GPIO.out)
GPIO.setclock("P9_22", 64000)  #and here 64000 = 64 khz
GPIO.output("P9_22",GPIO.HIGH)

naik...@gmail.com

unread,
Jul 18, 2014, 11:28:21 AM7/18/14
to beagl...@googlegroups.com
Can't be done in Python.

/opt/source/beaglebone-universal-io/cape-universal-00A0.dts

Learn to compile the device tree files and how to make changes like this.

Python can't do everything, despite what every Python fan I've known claims.

Jeremiah 

Ardit Cuka

unread,
Jul 18, 2014, 1:54:33 PM7/18/14
to beagl...@googlegroups.com, naik...@gmail.com
Can you send me some links to do so. I fairly new to BB and dont't know what a lot of terms mean!

Guy Grotke

unread,
Jul 18, 2014, 6:01:49 PM7/18/14
to beagl...@googlegroups.com
I do this in my c programs all the time.  The SPI driver has a bunch of ioctl() calls to change anything.   If Python can't make those ioctl() calls but supports functions for reading and writing a hardware register, you might be able to open the SPI device and then call the register access functions to change the SPI clock divider to whatever you want.  Look in spruh73i.pdf to find the register to write.  It's all in terms of 48 MHz divided by N.
--

ky...@cranehome.info

unread,
Jul 21, 2014, 4:35:07 PM7/21/14
to beagl...@googlegroups.com
Cool, just learned something myself today!   Now that I think about it I think it's I2C where the speed is set in device-tree only.   

Ardit Cuka

unread,
Jul 21, 2014, 11:16:20 AM7/21/14
to beagl...@googlegroups.com
Ok I figured it out using python: 
        spi = SPI(0,0)
spi.mode=2
spi.msh=2000000 ( by changing this number will result in the clock frequency change with a max of 12.0 Mhz. SIMPLE AS THAT.)
spi.open(0,0)
Thanks for your answers. 

On Tuesday, July 15, 2014 4:38:30 PM UTC-4, Ardit Cuka wrote:
Reply all
Reply to author
Forward
0 new messages