I am starting to work with your OS v3.0.0p3 on the STM32F072C8 in IAR. So far, everything works well (OS, CAN and SPI are running properly), but now I am trying to get working I2C and I have some problems.
1. When I start the I2C before SPI, SPI do not work:
Code: Select all
//SPI works
canStart(&CAND1, &cancfg);
i2cStart(&I2CD1, &i2cfg1);
spiStart(&SPID1, &spi1cfg);
//SPI do not works
canStart(&CAND1, &cancfg);
spiStart(&SPID1, &spi1cfg);
i2cStart(&I2CD1, &i2cfg1);
2. I am trying to send 2 bytes to EEPROM (I2C EEPROM address is 0xA0 and two bytes are 0x00, 0xAA). The transfer works well with ST hal (first picture - tek00005), but it sends only one byte with the ChibiOS hal I2C (second picture - tek00006) and the byte (probably I2C address) seems to be also wrong. The HW is for both cases same.
The code for sending the data in ChigiOS is like this:
Code: Select all
uint8_t i2cTxBuffer[2] = {0x00, 0xAA};
uint8_t i2cRxBuffer[8];
uint8_t status = 0;
...
static const I2CConfig i2cfg1 = {
STM32_TIMINGR_PRESC(0x02) | STM32_TIMINGR_SCLH(0x09) | STM32_TIMINGR_SCLL(0x0E),
I2C_CR1_PE,
I2C_CR2_AUTOEND
};
...
canStart(&CAND1, &cancfg);
i2cStart(&I2CD1, &i2cfg1);
spiStart(&SPID1, &spi1cfg);
...
if(Button[1].flags & BTN_SHORT)
{
i2cAcquireBus(&I2CD1);
status = i2cMasterTransmitTimeout(&I2CD1, 0xA0, i2cTxBuffer, 2, i2cRxBuffer, 8, MS2ST(100));
i2cReleaseBus(&I2CD1);
Button[1].flags &= ~(BTN_SHORT);
}
3. The TIMINGR wasn't set, I must switched the order of the registers initialization in the function i2c_lld_start in os\hal\ports\STM32\LLD\I2Cv2\i2c_lld.c, the TIMINGR before CR1 and CR2:
Code: Select all
/* Setup I2C parameters.*/
dp->TIMINGR = i2cp->config->timingr;
/* Reset i2c peripheral, the TCIE bit will be handled separately.*/
dp->CR1 = i2cp->config->cr1 | I2C_CR1_ERRIE | I2C_CR1_STOPIE |
I2C_CR1_NACKIE | I2C_CR1_TXDMAEN | I2C_CR1_RXDMAEN;
/* Set slave address field (master mode) */
dp->CR2 = (i2cp->config->cr2 & ~I2C_CR2_SADD);
Sorry for bothering you, I am pretty new to your OS so maybe I am just doing something trivial wrongly, but it would be very helpful for me if you can give me some hint at least for the problem number 2 because it is really blocking right now.
Thanks,
halba