cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030CC SMBus

karlis
Associate II
Posted on February 24, 2016 at 19:47

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
5 REPLIES 5
Posted on February 24, 2016 at 20:49

I'd strongly recommend the use of local variables, and the volatile keyword where appropriate. A lot of this stuff doesn't need global scope and you can contain issues more tightly.

Absent an asynchronous reset you might need to clock jammed up I2C peripherals out of stuck states. Watch for appropriate speed settings, and pull-ups. Avoid software only delay loops, if you need delays of specific lengths, ie 100us or 10ms, you really need to pace them and time-outs against a timer. Otherwise your system will be marginal and dependent on code placement, register utilization or optimization levels.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
karlis
Associate II
Posted on February 24, 2016 at 21:52

Ok, I will try to filter what you wrote tomorrow, I am really tired right now.

BTW that hung thing happened again and I have 3 screenshots with it!I would be really thankful if someone take a look at these: 

http://postimg.org/image/4s1b1fc9f/

http://postimg.org/image/v7dp2mfdd/

http://postimg.org/image/pkdumfbfp/

UART seems strange, any idea what is happening there? 

Posted on February 24, 2016 at 22:14

I think you need to set your iteration variables to zero/known values before you enter while() loops.

When you reset the I2C peripheral when it is busy, do you actually reconfigure it again? Also not sure resetting the I2C clears anything attached to the bus, just the STM32 side of it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
karlis
Associate II
Posted on February 25, 2016 at 10:41

I took out this reset function now.

I am trying to adjust my code so it is not such a mess.

Meanwhile can you please check this

http://postimg.org/image/rrdn7a96t/

Sometimes the 9th clock pulse for ACK bit is delayed, and I can't figure out why.

karlis
Associate II
Posted on February 25, 2016 at 16:37

I am not getting that error what I was talking about earlier, but this STOP mode after NACK doesn't seem OK.

Can someone approve my routine for SMBus command write and receive?

while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))
{
asm('''');
}
I2C_TransferHandling(I2C1, 0x16, 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);
I2C_SendData(I2C1, 0x8);
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))
{
asm('''');
}
I2C_TransferHandling(I2C1, 0x16, 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Read);
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_RXNE) == 0)
{
i++;
if (i == 10000) 
{
i = 0;
break;
}
}
i = 0;
temp = I2C_ReceiveData(I2C1);