cancel
Showing results for 
Search instead for 
Did you mean: 

Test/Clear EV7 i2c Std Peripheral Library- Help!!!!

estersci2
Associate III
Posted on October 12, 2015 at 17:59

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? 

Thanks

 

2 REPLIES 2
Posted on October 12, 2015 at 19:48

RM0090 rev.10, Fig.244

JW
jpeacock
Associate III
Posted on October 12, 2015 at 19:59

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