cancel
Showing results for 
Search instead for 
Did you mean: 

USART Interrupts appear to kill I2C bus on F4

jdp6q5
Associate II
Posted on April 20, 2013 at 17:42

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
3 REPLIES 3
Posted on April 20, 2013 at 18:17

Couple of observations:

sBuff3[bytesRecieved3] = (uint8_t) (USART3->DR & 0x000000FF); //grab the latest packet
bytesRecieved3++;
cnt--;
if (bytesRecieved3 > sBuffSize)

Your test here is flawed, C uses zero based indices, at 128 your already violating the buffer. It's Received BTW (I before E, except after C). Your interrupt handler seems to be designed to dwell there waiting for multiple bytes. Don't do that! Don't disable RXNEIE, just handle one byte at a time, accumulate them, and when you have enough process them. I haven't dug through all your logic there, but it looks to be unnecessarily complex, and could be done more simply/efficiently/correctly. Your string output function back tests the USART SR register for TC, you should front test for TXE before jamming data in DR, and not linger waiting for TC.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdp6q5
Associate II
Posted on April 20, 2013 at 21:56

I was originally handling bytes one at a time as they came in. It was place them in the buffer as they were read and move on. I changed to the blocking call you see now because it gave me fewer fits with the I2C bus. Whenever I would interrupt in the middle of an I2C read, the I2C bus would get stuck. This way, I'm blocking until I have my data, so at least I'm not messing up the I2C bus. It seemed to get messed up even with interrupts disabled. This helps with that. I agree. Normally I would not do that.

jdp6q5
Associate II
Posted on April 21, 2013 at 19:38

clive1, I took your suggestions and updated all my serial routines. Serial seems to work just fine now. I just can't seem to get I2C to work reliably. I switched to using 2K pull up resistors, I switched everything over to use I2C2 on pins PB10 and PB11. I even tried moving to a second 3.3V power supply. I just can't seem to get it to do I2C without issues. I have no idea what to even look at at this point to get it working, and the project is due in 4 days.