JeremyGrosser / rp2040_hal

Ada drivers for the Raspberry Pi RP2040 SoC
https://pico-doc.synack.me/
BSD 3-Clause "New" or "Revised" License
38 stars 11 forks source link

I2C Mem_Write sends a repeated start #33

Closed JeremyGrosser closed 2 years ago

JeremyGrosser commented 2 years ago

See conversation on Gitter for details.

hgrodriguez commented 2 years ago

as requested by Jeremy I am attaching the pictures of the logic analyser

this is the Micro Python version, which works: MicroPython_Write_Correct

this is the current RP implementation, which does not work: RP2040_Write_Wrong

and here after my very dirty hack: RP2040_Write_Correct

the hack (RP.I2C_Master.Mem_Write): declare My_Data : I2C_Data (0 .. Data'Last + 1); begin My_Data (0) := UInt8 (Mem_Addr); for Index in Data'Range loop My_Data (Index + 1) := Data (Index); end loop;

        This.No_Stop := False;
        This.Master_Transmit (Addr    => Addr,
                              Data    => My_Data,
                              Status  => Status,
                              Timeout => Timeout);
     end;
hgrodriguez commented 2 years ago

I am afraid, that maybe Mem_Read needs fixing, too.

JeremyGrosser commented 2 years ago

I changed Mem_Write to use a single Master_Transmit rather than a repeated start between address and data (5879969b90cb0890e3ab445f598431037e00973c).

Mem_Read needs the repeated start because it has to change the I2C address' LSB from write to read between sending the memory address and reading the data.

EEPROM write trace EEPROM read trace