cancel
Showing results for 
Search instead for 
Did you mean: 

Driver problem in stm32f30x_tim.h

JustMe
Associate II
Posted on October 20, 2015 at 12:58

Hi

The driver version I am using is * @version V1.0.1 * @date 23-October-2012 Is this an old version? If yes then where do I get a newer one? My problem is when I call some of the functions such as TIM_SelectInputTrigger then it overwrites values written by TIM_SelectSlaveMode. The problem appears to be the use of a 16 bit variable being used with a 32 bit variable. Perhaps it is just a setting I have wrong? In the function the variable tmpsmcr is 16 bit and when it is written back to the register the upper 16 bits is cleared. Any suggestions.. is this a bug or is this something I am doing wrong?

void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource)
{
uint16_t tmpsmcr = 0;
/* Check the parameters */
assert_param(IS_TIM_LIST2_PERIPH(TIMx)); 
assert_param(IS_TIM_TRIGGER_SELECTION(TIM_InputTriggerSource));
/* Get the TIMx SMCR register value */
tmpsmcr = TIMx->SMCR;
/* Reset the TS Bits */
tmpsmcr &= (uint16_t)~TIM_SMCR_TS;
/* Set the Input Trigger source */
tmpsmcr |= TIM_InputTriggerSource;
/* Write to TIMx SMCR */
TIMx->SMCR = tmpsmcr;
}

1 REPLY 1
qwer.asdf
Senior
Posted on October 20, 2015 at 14:29

It certainly looks like a bug, did you try changing the code? Something like this should work.

void
TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource)
{
uint32_t tmpsmcr = 0;
/* Check the parameters */
assert_param(IS_TIM_LIST2_PERIPH(TIMx)); 
assert_param(IS_TIM_TRIGGER_SELECTION(TIM_InputTriggerSource));
/* Get the TIMx SMCR register value */
tmpsmcr = TIMx->SMCR;
/* Reset the TS Bits */
tmpsmcr &= ~TIM_SMCR_TS;
/* Set the Input Trigger source */
tmpsmcr |= TIM_InputTriggerSource;
/* Write to TIMx SMCR */
TIMx->SMCR = tmpsmcr;
}

Also, why are you using the old version of the library, there is a

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF258144

(v1.2.3).