[문제 상황]
[해결]
uint8_t readBuffer[16];
uint8_t writteBuffer[16] = {0x05, 0x06, 0x07, 0x08, 0x09, 0x05, 0x06, 0x07, 0x08, 0x09, 0x05, 0x06, 0x07, 0x08, 0x09, 0x05};
HAL_StatusTypeDef rets = HAL_I2C_Mem_Write(&hi2c2, AT24C256C_addr, 0x00, 1, writteBuffer, 16, 1000);
HAL_Delay(1000);
HAL_StatusTypeDef ret = HAL_I2C_Mem_Read(&hi2c2, AT24C256C_addr, 0x00, 1, readBuffer, 16, 1000);
if (ret == HAL_OK) {
printf("success!! \n");
}else {
printf(" ret=%d, %ld : Fail !!!\n", ret, hi2c2.ErrorCode );
}
printf("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X \n",
readBuffer[0], readBuffer[1], readBuffer[2], readBuffer[3], readBuffer[4],
readBuffer[5], readBuffer[6], readBuffer[7], readBuffer[8], readBuffer[9],
readBuffer[10], readBuffer[11], readBuffer[12], readBuffer[13], readBuffer[14],
readBuffer[15]);
HAL_Delay(1000);
위처럼 코드를 작성하고나면 아래처럼 정상적으로 출력되는 모습을 확인할 수 있다.
[WP란?]
[교훈]