I have written a simple I2C Code for stm32f407 using the chibios HAL for interfacing mag QMC5883.
It's a Basic Single thread code, just trying to understand the Chibios HAL API for different peripherals.
Code is this: https://github.com/gkunalupta/RTOS-Chib ... OVERY2-I2C
But on running the code, it always gives Error +4, meaning Slave address Not ack, on checking in logic anal;yzer too, it shows as shown in below pic.
I have checked Connection many times and verified the API I am using from documentation, but I am not able to make out why is it still not working.
Any kind of inputs or insights will be very valuable.
I am guessing Maybe I am using the wrong API or some fault is in the firmware end only which I am not able to mark out.
STM32F407 I2C not Acknowledging
-
- Posts: 10
- Joined: Tue Jul 20, 2021 6:31 pm
- Has thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F407 I2C not Acknowledging
Hi,
A common error is to give the wrong address, the ChibiOS API requires the numeric address value (without the RW bit).
Giovanni
A common error is to give the wrong address, the ChibiOS API requires the numeric address value (without the RW bit).
Giovanni
-
- Posts: 10
- Joined: Tue Jul 20, 2021 6:31 pm
- Has thanked: 1 time
Re: STM32F407 I2C not Acknowledging
I know and have checked that thing, as you can see in the logic analyzer,
MAG I2C 7 bit slave address is 0b0001101
and that is what I am sending from code and its reflected in Logic Analyzer output.
I even tried with another I2C slave device, but it every time shows this, I2C slave address not Ack.
I am not getting what is the error I am making, stuck on it since past 3-4 days.
MAG I2C 7 bit slave address is 0b0001101
and that is what I am sending from code and its reflected in Logic Analyzer output.
I even tried with another I2C slave device, but it every time shows this, I2C slave address not Ack.
I am not getting what is the error I am making, stuck on it since past 3-4 days.
-
- Posts: 10
- Joined: Tue Jul 20, 2021 6:31 pm
- Has thanked: 1 time
Re: STM32F407 I2C not Acknowledging
What I mark out just know is that in logic analyzer output, as you can see
after the start signal both SCL and SDA lines are kept low for a period of time,
can that be the reason ????
after the start signal both SCL and SDA lines are kept low for a period of time,
can that be the reason ????
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F407 I2C not Acknowledging
I don't see i2cStart() called in there.
Enable assertions in chconf.h
Giovanni
Enable assertions in chconf.h
Giovanni
-
- Posts: 10
- Joined: Tue Jul 20, 2021 6:31 pm
- Has thanked: 1 time
Re: STM32F407 I2C not Acknowledging
Well, i2cstart() is called, it is not visible in the pic you can checkout main.c from git repo which I shared.
And when I enable the Debug assertion in chconf.h, I got following thing
does this mean my i2c clock is not ser properly??
what I can interpret from thus??
And when I enable the Debug assertion in chconf.h, I got following thing
does this mean my i2c clock is not ser properly??
what I can interpret from thus??
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F407 I2C not Acknowledging
Look at the stack trace up to the assert, the wrong condition is your problem.
Giovanni
Giovanni
Re: STM32F407 I2C not Acknowledging
In addition, you need to add PAL_STM32_OTYPE_OPENDRAIN to your I2C pad mode calls.
-
- Posts: 10
- Joined: Tue Jul 20, 2021 6:31 pm
- Has thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Who is online
Users browsing this forum: No registered users and 28 guests