Jump to content

I2C Driver Problems


newbornsun

Recommended Posts

Hello,

I am having some issues with I2C drivers in ChibiStudio. This might be unrelated to uGFX but thought someone might know whats going on.

In halconf.h I have defined "HAL_USE_I2C" as TRUE, however, when I checkout i2c_lld.h in os/hal/platforms/stm32/i2cv1 , the part under "#if HAL_USE_I2C" is grayed out indicating that that statement is not true (see picture). WHy is this the case if I have defined in halconf.h?? 

I am using logic analyzer and there is no action on the SCL line, just solid high when running the following code:

txbuf[0] = 0x00;  /* register address */
            i2cAcquireBus(&I2CD1);
            status = i2cMasterTransmitTimeout(&I2CD1, adxl345_addr, txbuf, 1, rxbuf, 1, tmo);
            i2cReleaseBus(&I2CD1);


I am thinking it has to do with the above observation. Any ideas?

 

Capture.PNG

Link to comment
Share on other sites

Never trust the Eclipse code analyzer thing. The µGFX library heavily relies on the pre-processor (macros) to optimize code during compilation. Those "simple" highlighters that IDEs like Eclipse come with simply can't cope with the complexity. Furthermore, some of our macros get changed automatically during compile time by the pre-processor so what you see prior to compilation is not necessarily what you get at the end.
The same applies to ChibiOS. Simply ignore what Eclipse tells you.

It has been a while since I last worked with ChibiOS. Is it possible that you forgot to enable I2C1? When I remember correctly you don't only need to enable I2C in general but also each individual I2C peripheral.
Also, don't forget so set you pin configurations correctly: You need to set them to the correct alternate function and depending on the STM32 that you're using even to open drain manually. This is a guide I wrote back a couple of years ago regarding I2C debugging/troubleshooting with ChibiOS, you might find that helpful: http://wiki.chibios.org/dokuwiki/doku.php?id=chibios:community:guides:i2c_trouble_shooting

In general the ChibiOS forum is more suited for this question.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...