Topic : Cannot STM8S I2C Stop bit with Raisonance compiler

Forum : ST7/STM8

Original Post
Post Information Post
November 22, 2010 - 9:44am
Guest

I have a STM8S I2C slave project on STM8S Discovery board. When the I2C interrupt service routine detects a I2C stop condition, the program calls I2C_ClearITPendingBit( I2C_FLAG_STOPDETECTION ) to clear the I2C_SR1 STOPF bit. However, when I used Raisonance compiler to build the project, the STOPF bit cannot be cleared. If I change the toolset to Cosmic compiler the same project can clear the STOPF bit correctly. Is this a bug in Raisonance compiler?
The following is the code in the stm8s_it.c for handling the I2C interrupt:
if ( I2C_GetITStatus( I2C_FLAG_ADDRESSSENTMATCHED ) == SET ) /* Check if Address Match */
{
/* Address Matched */
I2C_ClearITPendingBit( I2C_FLAG_ADDRESSSENTMATCHED );
address_match = 1;
}
if ( I2C_GetITStatus( I2C_FLAG_RXNOTEMPTY ) == SET )
{
i2c_data[i2c_data_ptr++] = I2C_ReceiveData( );
if ( i2c_data_ptr >= 10 )
{
i2c_data_ptr = 0;
}
}
if ( I2C_GetITStatus( I2C_FLAG_STOPDETECTION ) == SET )
{
I2C_ClearITPendingBit( I2C_FLAG_STOPDETECTION );
}

Replies
Post Information Post
+1
0
-1
November 22, 2010 - 5:41pm
Raisonance Support Team

Hi,

We are not aware of a problem of this kind on our tools.

First ensure that you are using the latest version of the Compiler (free download of RKit-STM8 from our Web site) as some compiler issues with the ST library have been fixed.
Also ensure that you execute WITHOUT the debugger attached. The I2C peripheral from STM8 is very sensitive and may not like the presence of the debugger, which may transparently read some peripheral bits hence change the device behavior.

Let us know if this fixes your problem.
Regards,

+1
0
-1
November 23, 2010 - 6:31am
Guest

Hi Bruno,
The compiler is relatively recent . The downloaded file is RKit-STM8_2.30.10.0175.exe.
This is STM8S Discovery board, it require a USB connection for the power supply. I run the program without starting the debugger and the result was the same: it cannot clear the I2C STOPF bit.
When I switched to Cosmic compiler and kept all other conditions same, the result was different. In that case the I2C STOPF bit can be cleared correctly.
In the program, I use the Green LED for indicating if the I2C STOPF bit being cleared without poping the register with the debugger.

+1
0
-1
November 23, 2010 - 9:52am
Raisonance Support Team

Hi,

We have not been able to reproduce the problem in our Labs.
Can you send a zipped project that shows the problem to "support (at) raisonance (dot) com", along with the necessary instructions about how to reproduce?

Thanks,

+1
0
-1
November 23, 2010 - 8:46pm
Guest

Hi Bruno,
I submitted the sample STM8S project to .
The program is for STM8S Discovery board. The project is ST Visual Studio because it works for STM8S Discovery board (I have tested this problem in Rid7 with my own PCB and the problem was in Rid7 project). In the main loop a counter is updated at each iteration. When it overflows and returns to 0 the green LED is toggled. You will see the LED blinking in normal condition. However, when the program receives the I2C packets (the 7-bit address is 0x20 and will become 0x40 in the first byte of I2C packet, followed 10 arbitrary bytes and stop condition. The speed is 100K bit/s), the stop bit (STOPF bit in I2C SR1) cannot be cleared. The interrupt service routine is then reentered repeatedly because of the STOPF assertion. As the result, the CPU cannot return back to the main loop and the LED stops blinking. I used Aardvark USB to I2C adapter to sending the I2C packets.
When I switch to Cosmic compiler, the LED will keep blinking after receiving the I2C packets.
I found this problem few months ago with Rid7 and Raisonace compiler. I thought it is a problem of the chip hardware and I submitted the ticket to ST Micro. After long time discussion the ST Micro tech support suggested me to try the Cosmit compiler and I then realized it is not the chip hardware problem but the compiler problem.

Thanks.