This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

i2c/twi detup on register level

Hello I'm trying to setup i2c/twi communication between nrf52832 with oled driver SH1107 but i need to do it in hardware instead of software but on the register level.

void initI2c()
{
	NRF_TWIM0->SHORTS = 0x00001780;
	NRF_TWIM0->INTEN = 0x019C0022;
	NRF_TWIM0->ERRORSRC = 0x00000006;
	NRF_TWIM0->PSEL.SCL	= 0x0000000D;
	NRF_TWIM0->PSEL.SDA = 0x0000000E;
	NRF_TWIM0->FREQUENCY = 0x06400000;
	NRF_TWIM0->ADDRESS = 0x0000078;
	NRF_TWIM0->ENABLE = 0x00000006;
}

void WriteTwiCommand (unsigned char Data)
{
	#define BUFFER_SIZE 2
	typedef struct ArrayList
	{
		uint8_t buffer[BUFFER_SIZE];
	} ArrayList_type;
	ArrayList_type MyArrayList[2];
	NRF_TWIM0->TXD.MAXCNT = BUFFER_SIZE;
	NRF_TWIM0->TXD.PTR = &MyArrayList;  // here it says (incompativle pointer to integer conversion when i copied that from the datasheet) 
	NRF_TWIM0->TASKS_STARTTX;
}

this is my code guys for the twi initialization and for sending transmission to slave. i need my nrf52 to act as a master only so i chose TWIM for that reason. im very new to communication protocols so please be patient with me. also if something in my question is not clear or missing, please let me know so i can clear it up as best i can.

Related