I2C driver by PRU

BTW, I believe the BeaglePilot project is running those drivers on the PRU, so this is the same as running on the Cortex-A8 bare-metal.

Regards,
John

I’d use Starterware as intended with a real RTOS like TI RTOS

BTW, I believe the BeaglePilot project is running those drivers on the PRU, so this is the same as running on the Cortex-A8 bare-metal.

I’ll take your word on that, as I have not really done much with that git project. Initially, I found it a waste of my time. Perhaps later I’ll revisit it and see what I missed.

But I also initially started learning how to use the ti-cgt PRU C compiler, but without CCS ( I prefer to stay as close to gcc as possible ), and found it rather difficult to proceed passed getting basic stuff working. So, I went back to attempting to “relearn” asm, and in the process learn PASM, and the PRU instruction set. Which of course initially I had a hard time with too, but I’m starting to understand more now.

Now I remember why I gave up on assembly so many years ago . . . the syntax is enough to make anyone “choke” . . .

hello Micka,

in attach you’ll find the archive with both asm and c sources: I’ve translated comments to english in order to make them more readable.

I’ve used https://github.com/beagleboard/am335x_pru_package as develop enviroment.

This example uses 2 I/O expanders (one for inputs and the other for outputs) and simply echoes the inputs to the outputs: the echo is done into the c code (that runs in the ARM core) with data passed to and for the PRU into the RAM.
The PRU manages the I2C1 module for init and refresh the I/O expanders.

Mux setting of I2C pins have to be done before execution.
It can’t be done by the PRU itself because the CONTROL_MODULE can’t be accessed (writing) by the PRU.
So I used cape-universal and a shell script for that.

iic_ioexp.zip (6.63 KB)

What kind of script ?? Can you post that? I would have thought mux-clock is done in a gel file

Thx GianFranco,

I managed to understand your code, which is well made.

My first test was to verify if I was able to compile the program and see if something goes out of the I2C 1.

And yes it works ! I saw something on the scope.

Now, I have to modify your code to be able to use the AD7997.

Thank you very much for your code and the comment !

Micka,

Hi,

William, I don’t get it …

Where do you see that the constant C2 == 0x4802_A000

Ah, ok got it. Page 25 of the PRU reference manual table 9

2 I2C1 0x4802_A000 == base address for i2c1

This link is removed, do you still remember / have the solution?