2023-04-19 02:33 AM
Hi,
i got some issue, where i restart a "5 times DMA" after i read the array. The first DMA is happening right after i startet it, when the level is high. But that is not a rising edge! I already made some test to verify this problem. The solution so far is, to wait for the signal to become low. But cpu time i valuable... A solution to this "solution" would be to check periodically is the signal is low, but that is also not so ideal (ugly and takes cpu time too).
in main loop:
if(dmaCompleted){
dmaCompleted = false;
// while(GPIOA->IDR & GPIO_PIN_8){
// //print("wait\n", 5); //wait for pin to become low, as a high level (not rising edge) will falsly trigger a dma request!
// }
LED3_GPIO_PORT->BRR = (uint32_t)LED3_PIN;
HAL_TIM_IC_Start_DMA(&htim1, TIM_CHANNEL_1, tim1_cpat_1, 5);
}
static void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_IC_InitTypeDef sConfigIC = {0};
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 65535;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_IC_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
sConfigIC.ICFilter = 0;
if (HAL_TIM_IC_ConfigChannel(&htim1, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
}
Interrupt:
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){
LED3_GPIO_PORT->BSRR = (uint32_t)LED3_PIN;
dmaCompleted = true;
}
Anyone has a solution, or can point me in the direction i can further investigate?
Cheers,
Toby