2017-06-30 12:52 AM
Hello,
First I am new in ST device, I only used Microchip PIC for 6 years.
So any advise or comment will be appreciated.
I am trying to use I2C interface on NucleoBoard F091RC1.
I2C_HandleTypeDef* hi2c1;
void i2cInit(I2C_HandleTypeDef* i2cHandler)
{// Assigned I2C handler pointer
hi2c1 = i2cHandler;// Call I2C init function
MX_I2C1_Init();}void MX_I2C1_Init(void)
{hi2c1->Instance = I2C1;
hi2c1->Init.Timing = 0x2000090E;
hi2c1->Init.OwnAddress1 = 0; hi2c1->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c1->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; hi2c1->Init.OwnAddress2 = 0; hi2c1->Init.OwnAddress2Masks = I2C_OA2_NOMASK; hi2c1->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c1->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; if (HAL_I2C_Init(hi2c1) != HAL_OK) { //Error_Handler(); }/**Configure Analogue filter
*/ if (HAL_I2CEx_ConfigAnalogFilter(hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) { //Error_Handler(); }}
In debug mode my code generate an hardware fault event on the first line of
MX_I2C1_Init function
.Would it be possible for someone to tell me what i am doing wrong ?
Thanks in advance.
Solved! Go to Solution.
2017-07-03 08:03 AM
Hello
COULIBALY.Youssouf
,Welcome to STM
Have a look to theworking
example within STM32F091RC-Nucleo available under
STM32CubeF0 firmware package:
STM32Cube_FW_F0_V1.8.0\Projects\STM32F091RC-Nucleo\Examples\I2C
You may re-use sections available in the example or get inspired from them.
Regards
Imen
2017-07-03 08:03 AM
Hello
COULIBALY.Youssouf
,Welcome to STM
Have a look to theworking
example within STM32F091RC-Nucleo available under
STM32CubeF0 firmware package:
STM32Cube_FW_F0_V1.8.0\Projects\STM32F091RC-Nucleo\Examples\I2C
You may re-use sections available in the example or get inspired from them.
Regards
Imen
2017-07-03 08:43 AM
I would start with CubeMX and enable the I2C1, then generate the code. This way you can easily setup clocking as well as every peripheral need to be clocked.
2017-07-03 11:33 PM
Hello Imen D,
Thanks a lot for your support. Now I get timer Interrupt. I have rewritten a weak function HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) in my cpp file.
Now I would lilke to do the same with HAL_DMA_TxCpltCallback(DMA_HandleTypeDef * hdma), but I cannot find any weak function with DMA complete callback.
Would it be possible to trigger a DMA complete without explicitly used a register callback function ?