2025-04-27 5:19 AM
Hi Support Team,
I am currently using the STM32U575ZIT6Q MCU for development.
As per our project requirements, I need to count six independent external pulse signals (from a wind-turbine RPM sensor or similar) with a maximum frequency of approximately 100 kHz.
The counter is expected to roll over naturally and reset upon system reboot (final hardware will use the STM32U585 series).
Here are my observations and concerns:
1. I had previously raised a similar query.
2. Could you please guide me on how to configure the timers to count at least six independent external inputs?
3. As per STM32CubeMX, the STM32U575ZIT6Q provides only 5 timers supporting ETR pins for external clock input.
4. I have observed that enabling certain configurations in Slave Mode disables other options like Trigger Source,
Clock Source, and Channel Configurations, leading to conflicts.
5. Could you suggest an alternative method to count six external pulse inputs? (Either using different channels or Interrupt, DMA method)
If possible, could you please share recommended STM32CubeMX configurations and/or example firmware code for this use case? Along with this I have attached a code of sample which I am usi
static void MX_TIM3_Init(void)
{
/* USER CODE BEGIN TIM3_Init 0 */
/* USER CODE END TIM3_Init 0 */
TIM_SlaveConfigTypeDef sSlaveConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM3_Init 1 */
/* USER CODE END TIM3_Init 1 */
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 4294967295;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_EXTERNAL1;
sSlaveConfig.InputTrigger = TIM_TS_ETRF;
sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED;
sSlaveConfig.TriggerPrescaler = TIM_TRIGGERPRESCALER_DIV1;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_ENABLE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM3_Init 2 */
/* USER CODE END TIM3_Init 2 */
}
void Timer_Handling_Thread(void *argument)
{
char iridium_buffer[64] = {0};
HAL_TIM_Base_Start(&htim5);
while(1)
{
uint32_t count = __HAL_TIM_GET_COUNTER(&htim5);
snprintf(iridium_buffer, sizeof(iridium_buffer),"Pulse Count: %lu (dec), 0x%lX (hex)\r\n", count, count);
HAL_UART_Transmit(&huart2, (uint8_t *)iridium_buffer, strlen(iridium_buffer), HAL_MAX_DELAY);
}
}
ng.
Your guidance would be very helpful as this directly impacts our hardware pin planning and overall system design.
Waiting for your response.
Thanks and Regards,
Ramesh
2025-04-27 4:17 PM
Related/duplicate:
Count External Clock pulses - STMicroelectronics Community