cancel
Showing results for 
Search instead for 
Did you mean: 

Hi I have a problem with I2C: I cant make it send 1st byte(addr) properly (10%-20% of the time)

YWhit
Associate III

my init:

I2C1->TIMINGR= 0xB0420F13; //p942  p917  XTAL=48MHZ

I2C1->MY_I2C->TIMEOUTR= 0x0000900A; //p943

I2C1->CR1=1;

no irq are involved (yet)

then I'm trying to start a frame (slave not connected- still- I would like I2C to send 1st byte)

I2C1->CR2=0x000300AB; //addr=0xAB

I2C1->CR2=0x000320AB; // "START"

the ST does send a 1st byte (SCL baud ok)- BUT its SDA pin sends a 0x00 instead of 0xAB - for about 10%-20% of the times. (from scope)

Ive tryed to put some delays between commands, clear all prev errors, looked at the addr reg. NOTHING makes the problem go away

thanks

Yona

9 REPLIES 9
YWhit
Associate III

3rd line should be I2C1->TIMEOUTR= 0x0000900A; //p943

> the ST does send a 1st byte (SCL baud ok)- BUT its SDA pin sends a 0x00 instead of 0xAB - for about 10%-20% of the times. (from scope)

Isn't SDA stuck low, do you see SDA high before START?

Can't that be a misbehaving "other party" (i.e. chip connected to the bus, supposedly slave)?

Is there no other code running on that chip?

What pullup are you using?

Which G0? Which pins? Can you try on a "known good" board e.g. Nucleo?

JW

YWhit
Associate III

Hi

SDA not stuck: it allows an ack(to be recived) by going high(pull up) after 8th bit. also- "outside" the byte - SDA is high.

as Im having a problem in 1st byte- I didnt connect any slave yet. (only scope)

the code I sent- runs on request (from UART). yet- thats the only code relevant to I2C. nothing is at backround/irq- as I cant get there without solving this issue.

Im using the internal pullups- and it shows- as rise time isnt immidiate (fall is immidite)

Im using the nucleo debug circuit with STM32G071 SCL=PB8 SDA=PB9. Ive also swaped to another debug circuit- same problem.

If nothing would be working- yet: 80% of attempts- does work(?????)

more:

checking I2C1->CR2 immiditly after a fail- reads out address bits properly (0xAB).

moreover: if I read SR1 to a register(elsewhere in ASM) then it reads nonsence- yet if I run the read in single step- it reads fine.

(this rutine isnt active now)

Im probebly missing something- like power/clock/something else to I2C. still baud is ok, 80% of the time- it does work

??????

You don't overclock the chip, do you? Try some low clock setting, possibly running from internal RC oscillator.

> Ive also swaped to another debug circuit- same problem.

Does this mean a different I2C module, or just different pins?

JW

(As you may have guessed, I have NO IDEA what might cause the problem).

YWhit
Associate III

Im working with 48Mhz. everything else works (GPIO,UART,TIMERS...). also the baud of the SCL is fine

and Ive init I2C1->TIMINGR acording to the table (48Mhz=> 100Khz I2C) . this does result to a 100Khz baud

Ive swaped circuits thinking the problem might be related to a specific chip. same issue in both chips.

pins PB8/PB9 are not connected to anything in the denug circuit

Okay so why don't you just try low frequency and different I2C/pins? Perhaps in an absolute minimal code (i.e. no UART, timers, etc)

You are desperate anyway, aren't you?

JW

YWhit
Associate III

so... tryed to use I2C2: works there !!!!

this means that I2C1 just might contain a bug ? (hard for me to believe)

should I report this issue to ST for them to check it further ?

nothing to do with desperation: though I would rather not get stuck in something like that - for more then a day's work

thanks again for the discussion

Did you change only I2C1->I2C2 (plus the respective change in enabling clocks and in GPIO), or did you write an entirely new minimal program?

> should I report this issue to ST for them to check it further ?

Yes, but they probably will ask you the same questions, and will ask you to provide some minimal code too...

JW

YWhit
Associate III

Ive changed all:

pin configuration,enabled I2C2 pwr,clock, all refernce to I2C1-> changed to I2C2->

I dont mind helping ST to analyze my problem: maby it realy is a bug in the micro (?)

after all: this isnt my 1st question in this forum- and they were all answered - solving issues I had.

thanks again for all

Yona