STM32F4 DSP and standard peripherals library - bug in I2C_CheckEvent() ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
ā2016-05-07 7:00 AM
Posted on May 07, 2016 at 16:00
Reference manual RM0383, ''STM32F411xC/E advanced ARMĀ®-based 32-bit MCUs'', says:
6.7 I2C Status register 2 (I2C_SR2) Note: Reading I2C_SR2 after reading I2C_SR1 clears the ADDR flag, even if the ADDR flag wasset after reading I2C_SR1. Consequently, I2C_SR2 must be read only when ADDR is foundset in I2C_SR1 or when the STOPF bit is cleared. But theSTM32F4 DSP and standard peripherals library, STSW-STM32065, does not do this in I2C_CheckEvent():ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT)
{
uint32_t lastevent = 0;
uint32_t flag1 = 0, flag2 = 0;
ErrorStatus status = ERROR;
/* Check the parameters */
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_I2C_EVENT(I2C_EVENT));
/* Read the I2Cx status register */
flag1 = I2Cx->SR1;
flag2 = I2Cx->SR2;
flag2 = flag2 << 16;
It will always read SR2 immediately after SR1 - without any attempt to check ADDR or STOPF.
I guess it should look something like this:
/* Read the I2Cx status registers */
flag1 = I2Cx->SR1;
/*
* RM0383 states, ''I2C_SR2 must be read only when ADDR is found
* set in I2C_SR1 or when the STOPF bit is cleared''
* See section 6.7 I2C Status register 2 (I2C_SR2) on page 492 (Rev 1).
*/
if( (flag1 & I2C_SR1_ADDR) ||
(flag1 & ~I2C_SR1_STOPF) )
{
flag2 = I2Cx->SR2;
}
else
{
return ERROR;
}
(can't raise a ticket on this as the system is down for ''upgrades'').
This is in the current 1.7.0 library release, and previous releases.
#library #stm32f4 #i2c
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
A complex system designed from scratch never works and cannot be patched up to make it work.
Labels:
- Labels:
-
I2C
-
STM32F4 Series
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
ā2016-05-23 9:42 AM
Posted on May 23, 2016 at 18:42
Hi neil.andrew,
Thank you for your feedback. The issue has been reported internally.-Syrine-Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
ā2016-05-23 12:32 PM
Posted on May 23, 2016 at 21:32
Download page says F4 DSP 1.7.1 but is actually 1.7.0 per directory
Can we get an update of the forum post linking to all old firmware releases, please.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
