2021-08-26 10:44 PM
Hi all,
I am trying to use I2C DMA as Master and UART DMA
My code is
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if (c == 1) {
HAL_UART_Transmit_DMA(&huart2, (uint8_t *)b, 8);
} else {
/* I2C Transmit code */
}
c = 1 - c;
}
and which I tried are (instead of /* I2C Transmit code */) :
// 1. polling, it worked
HAL_I2C_Master_Transmit(~~, 50);
HAL_I2C_Master_Receive(~~, 50);
// 2. DMA, not worked
HAL_I2C_Master_Transmit_DMA(~~);
HAL_I2C_Master_Receive_DMA(~~);
// 3. Mem read dma, not worked
HAL_I2C_Mem_Read_DMA(~~);
// 4. Seq DMA, not worked
HAL_I2C_Master_Seq_Transmit_DMA(~~, I2C_FIRST_FRAME);
HAL_I2C_Master_Seq_Receive_DMA(~~, I2C_LAST_FRAME);
I have no Idea whats wrong and how to solve it
thanks
2021-08-30 03:18 AM
Hi @Frogram ,
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-08-30 04:40 AM
Hi
2021-08-30 04:46 AM
Yes it is MX_DMA_Init().
Please make sure that it is called after MX_I2C_Init().
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-08-30 05:01 AM
The code was already set as you said. TT
2021-08-30 05:32 AM
I wanted to discard the fact that root cause of your issue is generated initialization code by STM32CubeMX.
Now it should be better to try to run I2C in DMA mode as a standalone application.
If it is working, then check interrupts priority.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-08-31 12:31 AM
how should I set priority? one of them as higher?
2021-09-01 08:01 AM
I2C is time-sensitive. It is recommended to set higher priority for its interrupts.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-09-09 04:42 AM
Hi @Frogram ,
Sorry, what I said in my previous comment is wrong:
Yes it is MX_DMA_Init().
Please make sure that it is called after MX_I2C_Init().
In fact, I2C initialization modifies some DMA register and needs its clock to be activated (here an explanation provided by TDK).
That is why it is required to call MX_DMA_Init() first then MX_I2C_Init(). STM32Cub eMX has to do this for you, but it is a regression in 6.3.0 version.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.