I2C2_IRQHandler requires IO access to work?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

I2C2_IRQHandler requires IO access to work?

跳至解决方案
864 次查看
bennoack
Contributor II

I am writing a I2C2_IRQHandler and cannot get it to work without accessing the FIO banks. I can see it work perfectly in the oscilloscope when I include any FIO access. Even if the gpio access does nothing at all but read a register and do nothing with the result - that seems to be enough to make it happy. As soon as I remove it all I get is a start transmission and then NOTHING. Its like the SI bit isn't getting cleared anymore.

My code can be found at blueboard/i2c.c at master · benjaminjnoack/blueboard · GitHub 

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
729 次查看
bennoack
Contributor II

I solved it! I was attempting to write to the I2DAT register before clearing the SI bit. From the user manual:

This register contains the data to be transmitted or the data just received. The CPU can
read and write to this register only while it is not in the process of shifting a byte, when the
SI bit is set. Data in I2DAT remains stable as long as the SI bit is set.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
730 次查看
bennoack
Contributor II

I solved it! I was attempting to write to the I2DAT register before clearing the SI bit. From the user manual:

This register contains the data to be transmitted or the data just received. The CPU can
read and write to this register only while it is not in the process of shifting a byte, when the
SI bit is set. Data in I2DAT remains stable as long as the SI bit is set.

0 项奖励
回复
729 次查看
bennoack
Contributor II

I've discovered a few things since my first posting.

It doesn't have to be FIO access; I can put a printf statement at the bottom of the IRQ and it will work fine. If I remove the print statement then I just get the start condition again. Even stranger, the length of the print statement affects how much of the I2C message is transmitted or received! If the print message is just a newline character then it works great, my test program of sending or receiving 5 bytes works perfectly. If the print message is "hello" then I only get half of the message. If the print message is "hello world" then I only get two bytes of it. Extremely bizzare! There is something I'm not seeing...

0 项奖励
回复