Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: akispol on January 22, 2023, 07:30:34 PM

Title: a20 i2c speed change
Post by: akispol on January 22, 2023, 07:30:34 PM
Hi all

I work with an A20 micro
with Debian GNU/Linux 11 (bullseye) and version 5.10.105-olimex

I wont to change i2c channel 2 to speed down to 50Khz in order to work with
a slow custom device. There is a way or patch to make this change ?

Thank you in advance
Title: Re: a20 i2c speed change
Post by: LubOlimex on January 24, 2023, 10:53:22 AM
Maybe try to alter the register directly:

https://raw.githubusercontent.com/allwinner-zh/documents/master/A20/A20_User_Manual_v1.4_20150510.pdf

6.2.4.6. TWI CLOCK REGISTER

The I2C2 address is 0x01c2b400
The offset of the clock register is 0x14

Remember that registers will revert back to defaults on power down or restart.
Title: Re: a20 i2c speed change
Post by: akispol on January 24, 2023, 07:48:38 PM
Thank you LubOlimex
Its a good idea but how can we write to a internal register using c language ?
This address is like a memory location or not ?
Title: Re: a20 i2c speed change
Post by: LubOlimex on January 25, 2023, 08:32:04 AM
Yes, it is pretty easy to experiment since even if something goes wrong you can just restart the board and most values would revert back to default.

You can alter values in the registers with devmem tool, you can download and compile it like:

apt-get install gcc
wget https://raw.githubusercontent.com/hackndev/tools/master/devmem2.c
gcc devmem2.c -o devmem
chmod +x devmem

then use like:

./devmem <address> w <value>

Remember that registers will revert back to defaults on power down or restart.
Title: Re: a20 i2c speed change
Post by: akispol on January 25, 2023, 07:48:50 PM
Thank you very much LubOlimex
I will try it

Have a nice day