- I'm thinking the problem could be the MODRR register. What should I be setting it to, if anything?
Check the port integration module (s12dp256pimv3.pdf). I2C is not routable to different pins. It is easy to check by looking at pin diagram. If you would see more than one instance of SDA or SCL, then I2C module would be routable to different pins and you would need to check module routing register (MODRR) settings.
- I am fairly certain that the actual I2C functions that I'm using (I2C_Open() and I2C_Send()) are correct.
Your code is wrong. It ALWAYS helps to look into datasheet and at your code again and again. What is TEA6320 protocol? It is 1) address byte, which is always 0x80 for this device, 2) subaddress (register number like volume, bass etc), 3) data. Now look at your code. It is 1) address, 2) subaddress, 3) again subaddress, 4) data.
- In addition, I added a timer wait of 250ms at the end of the I2C_Send() function to ensure that the slave device has enough time to process the request.
It is useless on I2C. Master can't go further while slave is busy.
AN3291 is good example of dangerous code. First of all why do thy wait for RXAK? RXAK is updated when byte is transferred to the slave. RXAK is updated as soon as IBIF is set and won't get updated until next byte is transferred to the slave. In case of failure, when for some reason slave doesn't ack your data, your MCU will stuck in endless loop waiting for RXAK that will never occur because your MCU doesn't transfer more bytes because it is waiting for RXAK. If you expect RXAK=0 and it is =1, then you should signal error, change direction to read, read dummy byte from data register, generate stop condition and exit.