2015-10-12 08:59 AM
Hi,
I think I have traced my problem with my big combined i2c DMA project.I need to test on EV7 and clear it after receiving every byte - but the Std Peripheral Library firmware doesn't seem to have a command for that - only EV5 etc.Its a one line fix - please does anybody know how to do this? Thanks2015-10-12 10:48 AM
RM0090 rev.10, Fig.244
JW2015-10-12 10:59 AM
EV7 occurs when you receive data from the I2C bus. You have to test for two events: Master byte received, with BTF set; and master byte receiving, BTF not set. For either event you have to send an early NAK at the N (message length) - 2 mark if the message is 2 or more bytes, or at the N - 1 mark if the message is only one byte.
if you are at the N - 2 state check the BTF flag after sending the NAK. Wait for BTF to set before reading the DR register (you can exit the interrupt at this point instead of a spinlock). This guarantees you have the proper NAK timing for the N - 1 state. Don't enable RX DMA at the EV6 state if you only have a one byte message. That special case has to be handled by interrupts alone. After the NAK check read the DR register to clear the EV7 event. If this isn't working then you aren't sending the NAK at the right time to stop the data transfer. Jack Peacock