I2C bitrate

Just about everything about Red Pitaya
Post Reply
thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

I2C bitrate

Post by thomasliuchang » Wed Nov 23, 2016 10:15 am

Hello everyone,

We used the i2c of RP to control some slave devices. Now, we find out that bitrate of I2C is 400k, which is too fast for our application. Is there a possibility to lower the rate to 100k? Thank you very much!

Best,
Chang

pavel
Posts: 799
Joined: Sat May 23, 2015 5:22 pm

Re: I2C bitrate

Post by pavel » Wed Nov 23, 2016 10:46 am

It should be possible by specifying the following Linux kernel boot argument:

Code: Select all

cdns-i2c.baudrate=100000
Boot arguments can be added by editing the bootargs variable in u-boot.script:
https://github.com/RedPitaya/RedPitaya/ ... oot.script

thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Re: I2C bitrate

Post by thomasliuchang » Wed Nov 23, 2016 11:56 am

Thanks for your fast response.
May I ask you where could I put the boot argument?

Code: Select all

cdns-i2c.baudrate=100000
I didn't find the patches folder on the SD card. There is a boot.script in the sd card. I open the boot.script.

Code: Select all

setenv high        0x1c000000
setenv fdt_high    ${high}
setenv initrd_high ${high}

echo Loading from SD card (FAT file system) to memory
mmcinfo
fatload mmc 0 0x2001000 uImage
fatload mmc 0 0x4000000 devicetree.dtb

echo Booting Linux kernel with ramdisk and devicetree
setenv bootargs console=ttyPS0,115200 root=/dev/mmcblk0p2 ro rootfstype=ext4 earlyprintk rootwait
setenv sdboot bootm 0x2001000 - 0x4000000
setenv bootdelay 0
bootd
I add the argument in the file, but the RP doesn't work anymore.

Could you please give me an example?

Best,
Chang

pavel
Posts: 799
Joined: Sat May 23, 2015 5:22 pm

Re: I2C bitrate

Post by pavel » Wed Nov 23, 2016 12:57 pm

I'd add it to the bootargs variable:

Code: Select all

setenv bootargs console=ttyPS0,115200 root=/dev/mmcblk0p2 ro rootfstype=ext4 earlyprintk rootwait cdns-i2c.baudrate=100000

pavel
Posts: 799
Joined: Sat May 23, 2015 5:22 pm

Re: I2C bitrate

Post by pavel » Wed Nov 23, 2016 1:19 pm

Correction to my previous posts. Apparently, I was looking at a wrong place and the cdns-i2c driver doesn't have baudrate parameter.

It's still possible to change the rate via the device tree:
  • convert devicetree.dtb to devicetree.dts

    Code: Select all

    dtc -I dtb -O dts -o devicetree.dts devicetree.dtb
  • edit devicetree.dts and replace

    Code: Select all

    clock-frequency = <0x61a80>;
    with

    Code: Select all

    clock-frequency = <0x186a0>;
  • convert devicetree.dts to devicetree.dtb
    dtc -I dts -O dtb -o devicetree.dtb devicetree.dts

thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Re: I2C bitrate

Post by thomasliuchang » Wed Nov 23, 2016 2:09 pm

Hi Pavel,

It works perfectly with the revised devicetree.dtb. Thank you very much!

Best,
Chang

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 72 guests