a20 i2c speed change

Started by akispol, January 22, 2023, 07:30:34 PM

Previous topic - Next topic

akispol

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

LubOlimex

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.
Technical support and documentation manager at Olimex

akispol

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 ?

LubOlimex

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.
Technical support and documentation manager at Olimex

akispol

Thank you very much LubOlimex
I will try it

Have a nice day