This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Have some troubles with hardware i2c

I try to use hardware i2c on XC161CJ with TimeKeeper M41T56. As examle, take source code from C161 manual, but there are some trouble.
May be, some of fachmans have little succesfull example of hw i2c ?

Parents Reply Children
  • Thanks, Andrew, for your answer.
    In two words, problem look so.
    As ground for my primitives, I use code
    from C161... User Manual. And in some cases
    it work good. But, when I compile it with
    another Code Optimization Level ( Keil ),
    the program do not set initial adress in
    timekeeper memory. I see as Keil work in
    different way, but, at my look, all is
    correct and I can't understand this
    dependencies ( now :)). I think, the reason is in my poor understanding of hardware i2c work.
    I solve this in real project with software
    i2c protocol, but in case with tight real
    time requirements it is not good.
    Certainly, this kind of bugs is difficult to discuss here.

    Thanks anyway,
    Good luck,
    Valery

  • "I think, the reason is in my poor understanding of hardware i2c work."

    If changing optimisation levels breaks your code, it could be your understanding of optimisation?

    Have you been sure to use the 'volatile' keyword where necessary?

    Are you relying upon 'C' software loops for timing?

    Did the C161 User Manual make any specific mention of optimisation? Or any other restrictions/limitations/warnings?

  • Thanks, Andy, for your advices. They force
    me to explore this question more accurate.
    I find out, that at max speed ( 40MHz CPU,
    all timings of external memory = 0 ), some
    delays between operation with i2c registers
    are critical. I don't like _nop_s at all, but
    in this case they are really needed.
    If you wish, I can prepare little project
    to demonstrate my exploring.
    My mail is ( divided to avoid spam-amateur )

    larry_
    @
    aport2000
    .
    ru

    Best wishes,
    Valery