2021-07-25 08:30 AM
In cubemx, the config of Tim12 TGRO is missing.
Where in tim1, i can config it under Trigger Out Parameter. This feature is required by DMA request generator.
I tried manually add some code to init this, but none of them work.
/* USER CODE BEGIN TIM12_Init 1 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC1REF;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&htim12, &sMasterConfig);
/* USER CODE END TIM12_Init 1 */
The DMA is used to transfer GPIO to memory
uint32_t test[100] __attribute__((section(".ARM.__at_0x24000000")));
//ignore some code here
HAL_DMA_Start(&hdma_dma_generator0,&GPIOB->IDR,test,100);
2021-07-25 09:37 AM
TIM12 doesn't have a TRGO signal.
Only master timers have this capability.
This is not available to be configured by HAL because of limitations in the library.
/**
* @brief Configures the TIM in master mode.
* @param htim TIM handle.
* @param sMasterConfig pointer to a TIM_MasterConfigTypeDef structure that
* contains the selected trigger output (TRGO) and the Master/Slave
* mode.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
TIM_MasterConfigTypeDef *sMasterConfig)
{
uint32_t tmpcr2;
uint32_t tmpsmcr;
/* Check the parameters */
assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
...
/****** TIM Instances : master mode available (TIMx_CR2.MMS available )********/
#define IS_TIM_MASTER_INSTANCE(INSTANCE) (((INSTANCE) == TIM1) || \
((INSTANCE) == TIM2) || \
((INSTANCE) == TIM3) || \
((INSTANCE) == TIM4) || \
((INSTANCE) == TIM5) || \
((INSTANCE) == TIM6) || \
((INSTANCE) == TIM7) || \
((INSTANCE) == TIM8) || \
((INSTANCE) == TIM15))
2021-07-25 12:57 PM
Which STM32?
> Only master timers have this capability.
No. TRGO from various timers can trigger not only other timers, but in newer STM32 also DMAMUX/DMA, and ADC.
JW
2021-07-26 08:19 AM
Thx for reply.
It is stm32H743VIT.
2021-07-26 08:28 AM
Thx for reply.
I would wonder if i could use something like this.
I configured TM1_CH1 as DMA request. The TM1_CH1 output a 1MHz PWM wave.
HAL_DMA_Start(&hdma_tim1_ch1,&GPIOB->IDR,test,100);
As far as i understand, DMA is like a interupt, so the request is not concerned with the srcAddr. But this failed to run.
Am i wrong? Hoping to hear from you!