I2C cannot write to TX_SADDR
Hey everyone 

I am trying to set up an I2C on my NEXYS 4 board without using the rt api from the sdk.
Now I think I have understood the way how the uDMA works an I am also able to transmitt something over the I2C (clock is there and a signal on the SDA is there too), but this are 
not the data I wanted to transfer.

My main problem now is, I am not able to write the address of my TX buffer to the TX_SADDR register. In the manual I can see that the TX_SADDR should be a read/write register but writing to it seams not be possible.
Does someone know what the problem could be or is there maybe an example how to setup peripherals connected to the uDMA without the help of the rt api?

Would really appreciate your help.

Thank you very much and have a nice day.

//in a headerfile called pulpissimo.h
#define I2C0_RX_SADDR    (*((volatile uint32_t *)0x1A102180))
#define I2C0_RX_SIZE    (*((volatile uint32_t *)0x1A102184))
#define I2C0_RX_CFG    (*((volatile uint32_t *)0x1A102188))
#define I2C0_TX_SADDR    (*((volatile uint32_t *)0x1A102190))
#define I2C0_TX_SIZE    (*((volatile uint32_t *)0x1A102194))
#define I2C0_TX_CFG    (*((volatile uint32_t *)0x1A102198))

//in hal_i2c.c
__attribute__((section(".l2_data"))) uint8_t tx_buff[BUFFERSIZE];
__attribute__((section(".l2_data"))) uint8_t rx_buff[BUFFERSIZE];
__attribute__((section(".l2_data"))) uint8_t cmd_buff[BUFFERSIZE];

//in an initialisation function in hal_i2c.c
I2C0_RX_SADDR  |= (uint32_t)&rx_buff[0]; //after this there is 0x00000000 in the register
I2C0_RX_SIZE   |= BUFFERSIZE;            //after this there is 0x00000000 in the register
I2C0_TX_SADDR  |= (uint32_t)&tx_buff[0]; //after this there is 0x00000000 in the register
I2C0_TX_SIZE   |= BUFFERSIZE;            //after this there is 0x00000000 in the register

I2C0_CMD_SADDR |= (uint32_t)&cmd_buff[0]; //after this there is 0x00000000 in the register
I2C0_CMD_SIZE  |= BUFFERSIZE;             //after this there is 0x00000000 in the register
Have solved the problem.

Will add a link to a repository with my code and an explanation, if someone has a similar issue, later today.

Have a nice day.
Ok as I told here is my example project: https://gitlab.com/d_maurer/pulpissimo-i2c-example.git
The project only sends data over the I2C bus. A read function is not implemented yet but I will work on that later. Maybe I will also update the write function then.

Found the PULPissimo datasheet a little bit missleading cause I am not quite sure why there is a cmd buffer register in the I2C part. It seams like that this register is not really
needed. And also the uDMA clock configuration gate is not needed to send out data onto the I2C bus. Maybe someone can help me to understand that. Or maybe I will understand
if I am going to implement the receive function!? Maybe the cmd buffer is needed there?

But anyway, I was able to send data and for now I am ok with that.

Wish you all a nice evening.

Forum Jump: