linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cedric.madianga@gmail.com (M'boumba Cedric Madianga)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 2/5] i2c: Add STM32F4 I2C driver
Date: Thu, 12 Jan 2017 17:17:47 +0100	[thread overview]
Message-ID: <CAOAejn1MWjW5h+EvCtt3aLPAQfndro6PhLTZTRs95VTOfRBJxQ@mail.gmail.com> (raw)
In-Reply-To: <CAOAejn2pW20VPP_yGtvJ_ufvj6Xj1poBiiA2WqkALiaLyyONug@mail.gmail.com>

>>> > I don't understand scl_period = 1 ?s for Fast Mode. For a bus freqency
>>> > of 400 kHz we need low + high = 2.5 ?s. Is there a factor 10 missing
>>> > somewhere?
>>>
>>> As CCR = SCL_period * I2C parent clk frequency with minimal freq =
>>> 2Mhz and SCL_period = 1 we have:
>>> CCR = 1 * 2Mhz = 2.
>>> But to compute, scl_low and scl_high in Fast mode, we have to do the
>>> following thing as Duty=1:
>>> scl_high = 9 * CCR * I2C parent clk period
>>> scl_low = 16 * CCR * I2C parent clk period
>>> In our example:
>>> scl_high = 9 * 2 * 0,0000005 = 0,000009 sec = 9 ?s
>>> scl_low = 16 * 2 * 0.0000005 = 0,000016 sec = 16 ?s
>>> So low + high = 27 ?s > 2,5 ?s
>>
>> For me 9 ?s + 16 ?s is 25 ?s, resulting in 40 kHz. That's why I wondered
>> if there is a factor 10 missing somewhere.
>
> Hum ok. I am going to double-check what is wrong because when I check
> with the scope I always reach 400Khz for SCL.
> I will let you know.

There is one point I miss here that is described in the reference manual:
To reach the 400 kHz maximum I?C fast mode clock, the I2C parent rate
must be a multiple of 10 MHz.
So, contrary to what we said in a previous thread, 400 kHz could not
be reached with low frequencies.
In that way, we could compute CCR with duty = 0 by default.
So, I find another formula very close to the first one I pushed in the
first version:

In fast mode, we compute CCR with duty = 0:
t_scl_high = CCR * I2C parent clk period
t_scl_low = 2 *CCR * I2C parent clk period
So, CCR = I2C parent rate / 400 kHz / 3

For example with parent rate = 40 MHz:
CCR = 40000000 / 400000 / 3 = 33.333333333 = 33
t_scl_high = 33 * (1 / 2000000) = 825 ns > 600 ns
t_scl_low = 2 * 16 * (1 / 2000000) = 1650 ns > 1300 ns

It seems ok now.

Best regards,

Cedric

  parent reply	other threads:[~2017-01-12 16:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05  9:07 [PATCH v8 0/5] Add support for the STM32F4 I2C M'boumba Cedric Madianga
2017-01-05  9:07 ` [PATCH v8 1/5] dt-bindings: Document the STM32 I2C bindings M'boumba Cedric Madianga
2017-01-05  9:07 ` [PATCH v8 2/5] i2c: Add STM32F4 I2C driver M'boumba Cedric Madianga
2017-01-11  8:22   ` Uwe Kleine-König
2017-01-11 13:58     ` M'boumba Cedric Madianga
2017-01-11 14:20       ` M'boumba Cedric Madianga
2017-01-11 15:42         ` Uwe Kleine-König
2017-01-12 11:25           ` M'boumba Cedric Madianga
2017-01-11 15:39       ` Uwe Kleine-König
2017-01-12 11:23         ` M'boumba Cedric Madianga
2017-01-12 12:03           ` Uwe Kleine-König
2017-01-12 13:47             ` M'boumba Cedric Madianga
2017-01-12 17:49               ` Uwe Kleine-König
2017-01-12 20:58                 ` M'boumba Cedric Madianga
2017-01-12 21:10                   ` Uwe Kleine-König
2017-01-12 21:28                     ` M'boumba Cedric Madianga
2017-01-13  7:26                       ` Uwe Kleine-König
2017-01-13  8:29                         ` Wolfram Sang
2017-01-13  8:45                           ` Uwe Kleine-König
2017-01-13  9:36                             ` M'boumba Cedric Madianga
2017-01-12 16:17           ` M'boumba Cedric Madianga [this message]
2017-01-05  9:07 ` [PATCH v8 3/5] ARM: dts: stm32: Add I2C1 support for STM32F429 SoC M'boumba Cedric Madianga
2017-01-05  9:07 ` [PATCH v8 4/5] ARM: dts: stm32: Add I2C1 support for STM32429 eval board M'boumba Cedric Madianga
2017-01-05  9:07 ` [PATCH v8 5/5] ARM: configs: stm32: Add I2C support for STM32 defconfig M'boumba Cedric Madianga
2017-01-10  9:26 ` [PATCH v8 0/5] Add support for the STM32F4 I2C Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOAejn1MWjW5h+EvCtt3aLPAQfndro6PhLTZTRs95VTOfRBJxQ@mail.gmail.com \
    --to=cedric.madianga@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).