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: "Chris Chronopoulos"<chronopoulos.ch...@gmail.com>;
Date: Mon, Aug 3, 2020 10:00 AM
To: "Karl Palsson"<ka...@tweak.net.au>;
Cc: "libopencm3-devel"<libopencm3-devel@lists.sourceforge.net>;
Subject: Re: [libopencm3-devel] I2C on STM32L1?
Thank you! That helped me get up and running. There were two things I was
missing. First, the call to 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 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 libopencm3-examples?
_chris
On Sun, Aug 2, 2020 at 10:24 AM Karl Palsson <ka...@tweak.net.au> 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> 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> wrote:
> Hmm, well update - I figured out that I was missing the
> following line:
>
> rcc_periph_clock_enable(RCC_GPIOB);
>
> before my GPIO setup calls. Makes sense. The thing I'm confused
> about now is the clock speed. With i2c_set_fast_mode(), I get a
> clock speed of 178 kHz. With i2c_set_standard_mode(), it's 266
> kHz. Weird, shouldn't fast mode be.. faster?
>
> Also, one more thing: if I try and wait for "address
> transferred" by doing:
>
> while (!(I2C_SR1(I2C1) & I2C_SR1_ADDR));
>
> after the i2c_send_7bit_address() call, then it gets stuck
> here. So I think I am still doing something wrong with the
> setup.
>
>
> On Sat, Aug 1, 2020 at 6:00 PM Chris Chronopoulos <
> chronopoulos.ch...@gmail.com> wrote:
>
> > I've also noticed that if I put in the while-loops to check for
status
> > register updates, e.g.
> >
> > while (!((I2C_SR1(I2C1) &
I2C_SR1_SB)
> > &
(I2C_SR2(I2C1) & (I2C_SR2_MSL | I2C_SR2_BUSY))));
> >
> > Then this just gets stuck, confirming that the start condition is not
> > being sent.
> >
> > On Sat, Aug 1, 2020 at 5:52 PM Chris Chronopoulos <
> > chronopoulos.ch...@gmail.com> wrote:
> >
> >> Hi, just joined this list, not sure what the protocol is.. but I
have a
> >> question about getting I2C working on the STM32L1(52RE).
> >>
> >> First of all, I see that there are two versions of the I2C API:
v1 and
> >> v2. Can someone explain what the difference is between these?
From digging
> >> through the library, I can see that different device families
use different
> >> versions, e.g.:
> >>
> >> F0: v2
> >> F1: v1
> >> F2: v1
> >> F3: v2
> >> F4: v1
> >> F7: v2
> >> L0: v2
> >> L1: v1
> >> L4: v2
> >>
> >> So when following code examples, I guess I need to find examples
that use
> >> the v1 API. In libopencm3-examples, the only STM32 I2C v1
example I could
> >> find is this one for F1
> >>
<https://github.com/libopencm3/libopencm3-examples/tree/master/examples/stm32/f1/other/i2c_stts75_sensor>.
> >> Unfortunately, the i2c_setup() function in this code doesn't
compile for
> >> L1, because of some differences between the RCC and GPIO API's
(namely,
> >> RCC_AFIO and gpio_set_mode() are not defined for L1). So I made
some
> >> adjustments based on my best guesses, and ended up with this code
> >>
<https://gist.github.com/chronopoulos/d34de9b6119d4ec052451d6afaa99e79>,
> >> which compiles. But, when I monitor the I2C lines with a logic
analyzer, I
> >> see nothing. Dead silence.
> >>
> >> Am I missing something? Can anyone provide an example of I2C
being used
> >> on STM32L1?
> >>
> >>
> _______________________________________________
> libopencm3-devel mailing list
> libopencm3-devel@lists.sourceforge.net
> 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