Hello Cameron Ehlers
You didn't wait the ACK.
From your slave, you can know the I2C wave should be:

But, you check your own code, you just write the buffer and clear the flag, then no wait for the ACK.
I share some code which I wrote for the other slave, just for your reference:
void hal_dev_vz89_write_reg(I2C_MemMapPtr I2Cx_B, uint8 cmd, uint8 data, uint8 crc)
{
i2c_start(I2Cx_B);
i2c_write_byte(I2Cx_B, VZ89_I2C_ADDRESS|I2C_WRITE);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, cmd);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, 0X00);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, 0X00);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, 0X00);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, 0X00);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_write_byte(I2Cx_B, crc);
i2c_wait(I2Cx_B);
i2c_get_ack(I2Cx_B);
i2c_stop(I2Cx_B);
pause();
}
void i2c_give_nack(I2C_MemMapPtr p)
{
p->C1 |= I2C_C1_TXAK_MASK;
}
void i2c_give_ack(I2C_MemMapPtr p)
{
p->C1 &= ~I2C_C1_TXAK_MASK;
}
void i2c_repeated_start(I2C_MemMapPtr p)
{
p->C1 |= 0x04;
}
void i2c_write_byte(I2C_MemMapPtr p, uint8 data)
{
p->D = data;
}
uint8 i2c_read_byte(I2C_MemMapPtr p)
{
return p->D;
}
void i2c_start(I2C_MemMapPtr p)
{
i2c_set_master_mode(p);
i2c_set_tx_mode(p);
}
void i2c_stop(I2C_MemMapPtr p)
{
i2c_set_slave_mode(p);
i2c_set_rx_mode(p);
}
void i2c_wait(I2C_MemMapPtr p)
{
i2c_wait_cnt=0;
i2c_err_flag=0;
while((p->S & I2C_S_IICIF_MASK)==0)
{
i2c_wait_cnt++;
if(i2c_wait_cnt>0x00001000)
{
i2c_err_flag=1;
break;
}
}
;
p->S |= I2C_S_IICIF_MASK;
}
uint16 i2c_get_ack(I2C_MemMapPtr p)
{
if((p->S & I2C_S_RXAK_MASK) == 0)
return TRUE;
else
return FALSE;
}
Just add the wait ACK!
Wish it helps you!
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have