I2C Problem with STM32F4DISCOVERY in v2.4.0

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by Giovanni »

It seems that if there is a pending upgrade the software is unable to start with an error like "unable to create empty document", very informative...

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by barthess »

Hi there,
I can not reproduce the bug with ITG3200 gyro on my custom board (I have no STM32F4 discovery board nor CS43L22).
nactus
Posts: 5
Joined: Fri Dec 23, 2011 11:09 pm

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by nactus »

Hi,

I found my mistake:
In 'mcuconf.h' the define 'STM32_I2C_I2C1_DMA_PRIORITY' was set to 4 instead of 1.
I thought I switched out the 'mcuconf.h' but apparently I didn't. :?

So changing that solved my problem.
Sorry for the trouble and thanks for all your help.

Andreas
nactus
Posts: 5
Joined: Fri Dec 23, 2011 11:09 pm

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by nactus »

Hi,

I have one follow-up question:

Why does it matter if the dma priority is 4 or 1 if there is only one thing using dma? I thought you only needed priorities if there are two things "fighting" over "who comes first" or "who can interrupt whom"?
Or is the OS using dma as well, even if there is nothing else running?

Andreas
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by Giovanni »

Hi,

4 is out of range, DMA priorities go from 0 to 3, by specifying 4 you set to 1 the bit following the priority field in a DMA register:
x00
x01
x10
x11
100

Giovanni
JerryR
Posts: 9
Joined: Sun Apr 08, 2012 6:51 am

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by JerryR »

I confirm this problem exists.
BOARD: Gold Bull
MCU: STM32F107VCT6
EEPROM: 24LC02B (microchip)
CHIBIOS: 2.4.0
Sample my code:

Code: Select all

/*
 * Init I2CD1
 */
   i2cInit();
   i2cStart(&I2CD1, &i2cfg1);
   /* startups. Pauses added just to be safe */
   chThdSleepMilliseconds(100);
/*
 * Read 24LC02B EEPROM
 */
   /* sending */
   accel_tx_data[0] = 0x00; /* word addres address */
   i2cAcquireBus(&I2CD1);
   status = i2cMasterTransmitTimeout(&I2CD1, MC24LC02B_ADDR, accel_tx_data, 1, accel_rx_data, 1, tmo);
   i2cReleaseBus(&I2CD1);
   if (status != RDY_OK)//{errors = i2cGetErrors(&I2CD1);}
      {PRINT_STR("I2C MC24LC02B: write1 error\n\r");}
   else
   {
      PRINT_STR("I2C MC24LC02B: write1 ok :)\n\r");
      PRINT_UINT8_CON1_1("I2C data 0x", accel_rx_data[0], ";\n\r", buf);
   }
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by Giovanni »

Hi,

You are probably hitting another problem, because an STM32 limitation it is not possible to read one single byte using DMA, try to read at least two bytes.

Giovanni
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by DrunkenDonkey »

Pretty much everyone dealing with that hits this limitation, scratches the head, comes to the forum and either finds the solution or makes a topic. Would it be viable to have the "read 2, return 1" logic implemented in the st specific i2c part when 1 byte is requested over i2c? After all, you can't go much different in that case, like I have made wrappers over all i2c functions?
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: I2C Problem with STM32F4DISCOVERY in v2.4.0

Post by barthess »

@ DrunkenDonkey,
I think about that. The difficulty in decision what 2 bytes to read - needed and next or needed and previous. This problem must be solved by user for his needs. For example, reading 1 byte from the end and from the beginning of EEPROM device.

@ JerryR,
You can find driver for EEPROM (24 series) on https://github.com/barthess/24aa
Post Reply