Hi everyone,

  I usually have got your e-mail, why?
  

  I don't want to got your e-mail any more, how should I do?


  Tell me how to do please! Thank you very much, I would very please for 
that.

 
 
------------------ Original ------------------
From: &nbsp;"Chris Chronopoulos"<chronopoulos.ch...@gmail.com&gt;;
Date: &nbsp;Mon, Aug 3, 2020 10:00 AM
To: &nbsp;"Karl Palsson"<ka...@tweak.net.au&gt;; 
Cc: &nbsp;"libopencm3-devel"<libopencm3-devel@lists.sourceforge.net&gt;; 
Subject: &nbsp;Re: [libopencm3-devel] I2C on STM32L1?

&nbsp;

Thank you! That helped me get up and running. There were two things I was 
missing. First, the call to&nbsp;gpio_set_output_options() with GPIO_OTYPE_OD 
appears to be critical; it's not sufficient to put this in gpio_mode_setup(). 
Second, with GPIO_OTYPE_OD, apparently I need to use&nbsp;i2c_set_speed(), 
instead of i2c_set_clock_frequency() and/or i2c_set_fast/standard_mode().

After that, my address write received ACK. But I still was not able to use 
i2c_send_data(); this apparently did nothing. However, using i2c_transfer7() as 
you suggested, worked fine. So I am good for now (albeit a little confused 
about the old/low-level interface versus the new one..).


Would it be helpful for me to submit a working L1 I2C example 
for&nbsp;libopencm3-examples?


_chris






On Sun, Aug 2, 2020 at 10:24 AM Karl Palsson <ka...@tweak.net.au&gt; wrote:


 https://github.com/karlp/libopencm3-tests/tree/master/tests/i2c-master
 is the code I wrote while developing the "standard" api. (You
 shouldn't really have to know about the v1/v2 differences, for
 the most part...) Those "set_fast_mode" and "set_standard_mode"
 are part of the original very low level apis. you (probably) want
 something more like:
 
 
https://github.com/karlp/libopencm3-tests/blob/master/tests/i2c-master/i2c-master.c#L29-L38
 (i2c_set_speed() and then just i2c_transfer7()
 
 The main-<hardware&gt; have the onnly board specfic setup required,
 normally setting up clocks and gpio modes.
 
 There's a couple of issues reported with i2c as well:
 https://github.com/libopencm3/libopencm3/pulls?q=is%3Apr+is%3Aopen+i2c
 that _may_ be relevant to you, or at least to bear in mind.
 
 
 Chris Chronopoulos <chronopoulos.ch...@gmail.com&gt; wrote:
 &gt; Hmm, well update - I figured out that I was missing the
 &gt; following line:
 &gt; 
 &gt;&nbsp; &nbsp; &nbsp;rcc_periph_clock_enable(RCC_GPIOB);
 &gt; 
 &gt; before my GPIO setup calls. Makes sense. The thing I'm confused
 &gt; about now is the clock speed. With i2c_set_fast_mode(), I get a
 &gt; clock speed of 178 kHz. With i2c_set_standard_mode(), it's 266
 &gt; kHz. Weird, shouldn't fast mode be.. faster?
 &gt; 
 &gt; Also, one more thing: if I try and wait for "address
 &gt; transferred" by doing:
 &gt; 
 &gt;&nbsp; &nbsp; &nbsp;while (!(I2C_SR1(I2C1) &amp; I2C_SR1_ADDR));
 &gt; 
 &gt; after the i2c_send_7bit_address() call, then it gets stuck
 &gt; here. So I think I am still doing something wrong with the
 &gt; setup.
 &gt; 
 &gt; 
 &gt; On Sat, Aug 1, 2020 at 6:00 PM Chris Chronopoulos <
 &gt; chronopoulos.ch...@gmail.com&gt; wrote:
 &gt; 
 &gt; &gt; I've also noticed that if I put in the while-loops to check for 
status
 &gt; &gt; register updates, e.g.
 &gt; &gt;
 &gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (!((I2C_SR1(I2C1) &amp; 
I2C_SR1_SB)
 &gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp; 
(I2C_SR2(I2C1) &amp; (I2C_SR2_MSL | I2C_SR2_BUSY))));
 &gt; &gt;
 &gt; &gt; Then this just gets stuck, confirming that the start condition is not
 &gt; &gt; being sent.
 &gt; &gt;
 &gt; &gt; On Sat, Aug 1, 2020 at 5:52 PM Chris Chronopoulos <
 &gt; &gt; chronopoulos.ch...@gmail.com&gt; wrote:
 &gt; &gt;
 &gt; &gt;&gt; Hi, just joined this list, not sure what the protocol is.. but I 
have a
 &gt; &gt;&gt; question about getting I2C working on the STM32L1(52RE).
 &gt; &gt;&gt;
 &gt; &gt;&gt; First of all, I see that there are two versions of the I2C API: 
v1 and
 &gt; &gt;&gt; v2. Can someone explain what the difference is between these? 
From digging
 &gt; &gt;&gt; through the library, I can see that different device families 
use different
 &gt; &gt;&gt; versions, e.g.:
 &gt; &gt;&gt;
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F0: v2
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F1: v1
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F2: v1
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F3: v2
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F4: v1
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;F7: v2
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;L0: v2
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;L1: v1
 &gt; &gt;&gt;&nbsp; &nbsp; &nbsp;L4: v2
 &gt; &gt;&gt;
 &gt; &gt;&gt; So when following code examples, I guess I need to find examples 
that use
 &gt; &gt;&gt; the v1 API. In libopencm3-examples, the only STM32 I2C v1 
example I could
 &gt; &gt;&gt; find is this one for F1
 &gt; &gt;&gt; 
<https://github.com/libopencm3/libopencm3-examples/tree/master/examples/stm32/f1/other/i2c_stts75_sensor&gt;.
 &gt; &gt;&gt; Unfortunately, the i2c_setup() function in this code doesn't 
compile for
 &gt; &gt;&gt; L1, because of some differences between the RCC and GPIO API's 
(namely,
 &gt; &gt;&gt; RCC_AFIO and gpio_set_mode() are not defined for L1). So I made 
some
 &gt; &gt;&gt; adjustments based on my best guesses, and ended up with this code
 &gt; &gt;&gt; 
<https://gist.github.com/chronopoulos/d34de9b6119d4ec052451d6afaa99e79&gt;,
 &gt; &gt;&gt; which compiles. But, when I monitor the I2C lines with a logic 
analyzer, I
 &gt; &gt;&gt; see nothing. Dead silence.
 &gt; &gt;&gt;
 &gt; &gt;&gt; Am I missing something? Can anyone provide an example of I2C 
being used
 &gt; &gt;&gt; on STM32L1?
 &gt; &gt;&gt;
 &gt; &gt;&gt;
 &gt; _______________________________________________
 &gt; libopencm3-devel mailing list
 &gt; libopencm3-devel@lists.sourceforge.net
 &gt; https://lists.sourceforge.net/lists/listinfo/libopencm3-devel
_______________________________________________
libopencm3-devel mailing list
libopencm3-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel

Reply via email to