2024-01-10 05:44 AM
Hi,
I wan't to use the stm32 as described in the video
https://controllerstech.com/stm32-timers-9-one-pulse-mode/
with the difference that I uses the trm4 and the input trigger is channel 1.
Operation is ok but applying the signal from a 3.3v signal generator lowers it to 2.3v! It's as if the input resistance of the trigger was a little too low. But I can't find anything about this. I applied this same signal to an input on capture, and there no problem, the signal remains at 3.3v.
Do you have any idea about the cause of this drop in signal?
Michel
2024-01-11 04:26 AM
Just guessing : you drive a "big" signal directly to a cpu pin (no good idea anyway).
PB6 is your choosen pin, for trigger input - right ?
So when cpu running and digital input -> trigger connected + its input circuit might have protection diodes to gnd + vcc.
But on reset - "nothing" connected, pin is FT (5V tolerant) and only protection diode to gnd at pin; input impedance might be slightly higher, in giga-ohm range, so just any effect, if your signal generator has a Megaohm output impedance;
But now input signal at pin can be > 3vss ;
to check: connect a scope and look at the voltages .
2024-01-11 07:00 AM
Read out and check/post content of TIM and relevant GPIO registers.
JW
2024-01-26 06:35 AM
Hi,
instead of using
HAL_TIM_OC_ConfigChannel(...)
try to use
HAL_TIM_OnePulse_ConfigChannel(...)
and switch
TIM_OC_InitTypeDef sConfigOC = { 0 };
to
TIM_OnePulse_InitTypeDef sConfigOC = { 0 };
there you can set
sConfigOC.ICSelection = TIM_ICSELECTION_DIRECTTI;
Example:
static void MX_TIM8_Init(void)
{
TIM_SlaveConfigTypeDef sSlaveConfig = { 0 };
TIM_MasterConfigTypeDef sMasterConfig = { 0 };
//TIM_OC_InitTypeDef sConfigOC = { 0 };
TIM_OnePulse_InitTypeDef sConfigOC = { 0 };
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = { 0 };
htim8.Instance = TIM8;
htim8.Init.Prescaler = 200 - 1;
htim8.Init.CounterMode = TIM_COUNTERMODE_UP;
htim8.Init.Period = 1000 - 1; //Overall Length
htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim8.Init.RepetitionCounter = 1-1;
htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim8) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_OC_Init(&htim8) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_OnePulse_Init(&htim8, TIM_OPMODE_SINGLE) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_TRIGGER;
sSlaveConfig.InputTrigger = TIM_TS_TI2FP2;
sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_RISING;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchro(&htim8, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM2;
sConfigOC.Pulse = 990;//Delay of the Pulse
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
//sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
sConfigOC.ICSelection = TIM_ICSELECTION_DIRECTTI;
if (HAL_TIM_OnePulse_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_1, TIM_CHANNEL_2) != HAL_OK)
//if (HAL_TIM_OC_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
sBreakDeadTimeConfig.DeadTime = 0;
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
sBreakDeadTimeConfig.BreakFilter = 0;
sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
{
Error_Handler();
}
HAL_TIM_MspPostInit(&htim8);
}