cancel
Showing results for 
Search instead for 
Did you mean: 

iic with stm32f100

andreaslehmi9
Associate II
Posted on October 28, 2012 at 12:52

Hello,

i'm trying to access a compas modul with my stm32F100 (ST32VLDiscovery). I'm trying to do that directly accessing the registers. I think writing the data is ok, but reading doesn't work.

I send the start, than the address and after that I'm not sure if i have to send the data (0xFF) to produce the clock or if the clock is produced automatically. The informaiton in the manual concerning this are not clear.

Thanks in acvanced,

Andi
9 REPLIES 9
Posted on October 28, 2012 at 13:46

I2C on the STM32 part is fairly complicated. Suggest you review the flow expressed in the examples.

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\I2C\I2C_TSENSOR
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andreaslehmi9
Associate II
Posted on October 28, 2012 at 13:56

Thanks for your quick response!

No, I don't know the examples you mentioned. Where exactly can I get them? Could you please give me the link where to download them.

Thanks

zzdz2
Associate II
Posted on October 29, 2012 at 03:20

Resources on the ST website may be found via either the CHIP or BOARD support pages, although frankly a Google/Bing search might be more effective than ST's own search.

STM32F100RB, review Design Support tab

http://www.st.com/internet/mcu/product/216844.jsp

STM32 VL-Discovery

http://www.st.com/internet/evalboard/product/250863.jsp

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andreaslehmi9
Associate II
Posted on October 31, 2012 at 22:32

Hello,

sorry for the confusing messsage. I tried to post it with my android.

Thanks for your answers. That make things clearer for me now.

I have one more question:

what is the difference between RxNE and BTF. When is which bit set?

BTF makes sense for me when sending. But on receiving? When my receive buffer is not empty(RxNE=1) there should be also a transmision finished(BTF=1).

Thanks

Andi

zzdz2
Associate II
Posted on November 05, 2012 at 18:16

Maybe this will help, i found it in STM32F10x reference manual RM0008:

26.6.6 I2C Status register 1 (I2C_SR1)

 

[...]

 

Bit 2 BTF: Byte transfer finished

 

       0: Data byte transfer not done

 

       1: Data byte transfer succeeded

 

       ­Set by hardware when NOSTRETCH=0 and:

 

          ­In reception when a new byte is received (including ACK pulse) and DR has not been read yet (RxNE=1).

 

          ­In transmission when a new byte should be sent and DR has not been written yet (TxE=1).

 

          ­Cleared by software reading SR1 followed by either a read or write in the DR register or by hardware after a start or a stop condition in transmission or when PE=0.

 

      Note: The BTF bit is not set after a NACK reception

 

             The BTF bit is not set if next byte to be transmitted is the PEC (TRA=1 in I2C_SR2 register and PEC=1 in I2C_CR1 register)

 

andreaslehmi9
Associate II
Posted on November 07, 2012 at 12:49

Does that mean the different between the BTF and the RxNE is that the BTF is not set if there in a NACK while the RxNE is set in that case?

zzdz2
Associate II
Posted on November 07, 2012 at 13:22

I haven't used it so i can't tell.

It seems to suggest difference in ACK/NACK but who knows.

Generally ST documentation is not perfect so it's best to verify it in practice.

andreaslehmi9
Associate II
Posted on November 07, 2012 at 15:08

You are right, I'm going to figure out which bit works best for Receiving in IIC.

Thanks for your help.