Hello,
I am working on my own board. It is my first board which i made. I have a problem with I2C, when i try to send any byte, controller goes to busy state and never get out from busy state. I don't know why problem is, maybe caused of board and connection with sensors or software. So i wanna make sure that problem is about software or not.
Firstly, i am making clock configuration. I used 8Mhz crystal, my microcontroller is TM4C123GH6PM. System Clock is set 80Mhz
I am using PA6 and PA7.
Port PIN Configuration code is
GPIOA->DIR |= (1UL << 6);//I don't know it is necessary or not
GPIOA->AFSEL |= (1UL << 6) & (1UL << 7); // 6. and 7. pin configured as alternative mode
GPIOA->PCTL = 0x33000009UL; // 6. pin SCL 7.pin SDA, the others pins stay default
GPIOA->ODR |= 0x00000080UL; // PORTA 7. pin opendrain
GPIOA->DEN |= (1UL<<6) & (1UL<<7); // Port 6 and 7 is digital pin
I2C Configuration
I2C1->MCR = (1UL << 4); // Master Mode Enable I2C1->MTPR |= 0x09; // 80 Mhz Clock, 400kbps communication
Transmit One Byte Code
while(!(I2C1->MCS & (1UL << 5))); I2C1->MSA = (slave_adress << 1); I2C1->MDR = reg_adress; while(I2C1->MCS & (1UL << 6)); I2C1->MCS = 0x0000000F; while(I2C1->MCS & (1UL << 0)); // System stay here forever
and i saw that when i wrote on MDR register, i just see 0x00 insife of this register on debug mode.
Thanks