2016-01-06 09:39 AM
Hi!
I am trying to control two motors using an STM32F100RCT6TR microcontroller and the standard peripheral library version 3.5.0. I want to use TIM3 channel 1&2 and TIM12 channel 1&2. TIM3 works perfectly but I get nothing out of TIM12. None of the TIM12 registers that I look at using the debugging mode of IAR embedded workbench even seem to change form being 0. I figure since I initialize TIM12 the same way as TIM3 it should work. Does anyone know where I am doing it wrong?This is my initializing code: GPIO_InitTypeDef GPIO_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE ); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; GPIO_Init(GPIOC, &GPIO_InitStruct);TIM_TimeBaseInitTypeDef TIM_BaseStruct; //make a struct RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM12, ENABLE); //turn on clock for TIM12 TIM_BaseStruct.TIM_Prescaler = 0; //No prescaler TIM_BaseStruct.TIM_CounterMode = TIM_CounterMode_Up; //count up TIM_BaseStruct.TIM_Period = PWM_PERIOD; //(PWM_PERIOD=24000) TIM_BaseStruct.TIM_ClockDivision = TIM_CKD_DIV1; TIM_BaseStruct.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM12, &TIM_BaseStruct); //init TIM_Cmd(TIM12, ENABLE); //enable TIM12 TIM_OCInitTypeDef TIM_OCStruct; //Output compare struct TIM_OCStruct.TIM_OCMode = TIM_OCMode_PWM1; //clear on compare match TIM_OCStruct.TIM_OutputState = TIM_OutputState_Enable; TIM_OCStruct.TIM_OutputNState = TIM_OutputNState_Disable; TIM_OCStruct.TIM_Pulse = (uint32_t)(PWM_PERIOD*0.6); //60% duty cycle TIM_OCStruct.TIM_OCPolarity = TIM_OCPolarity_Low; TIM_OCStruct.TIM_OCNPolarity = TIM_OCNPolarity_High; TIM_OCStruct.TIM_OCIdleState = TIM_OCIdleState_Reset; TIM_OCStruct.TIM_OCNIdleState = TIM_OCNIdleState_Reset; TIM_OC1Init(TIM12, &TIM_OCStruct); //Initialize TIM12 channel 1 TIM_OC1PreloadConfig(TIM12, TIM_OCPreload_Enable); TIM_ARRPreloadConfig(TIM12, ENABLE); TIM_OCStruct.TIM_Pulse = (uint32_t)(PWM_PERIOD*0.6); TIM_OC2Init(TIM12, &TIM_OCStruct); //Initialize TIM12 channel 2 TIM_OC2PreloadConfig(TIM12, TIM_OCPreload_Enable); //Steering RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //turn on clock for TIM3 TIM_TimeBaseInit(TIM3, &TIM_BaseStruct); //init TIM_Cmd(TIM3, ENABLE); //enable TIM3 TIM_OCStruct.TIM_Pulse = (uint32_t)(PWM_PERIOD*0.5); //50% duty cycle TIM_OC1Init(TIM3, &TIM_OCStruct); //Initialize TIM3 channel 1 TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable); TIM_OCStruct.TIM_Pulse = (uint32_t)(PWM_PERIOD*0.5); TIM_OC2Init(TIM3, &TIM_OCStruct); //Initialize TIM3 channel 2 TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable); Best regards,Emil #stop-tap-dancing-around2016-01-07 01:45 AM
Hi eriksson.emil.001,
It seems that TIM12 is not available in the device you are using.In fact, you have to check the exact used revision.To be sure about the used revision of STM32F100 device, please check the exact value of ''DEV_ID'' field in DBGMCU_IDCODE register (0xE0042000):- If the value is 0x420 or 0x428, refer to RM0041- Otherwise, refer to RM0008.Based on the reference manual content, you can verify if TIM12 is available on your device or not.TIM12 is available only on devices with DEV_ID: 0x430 or 0x428.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-01-07 02:25 AM
This is an area in which your documentation is VERY weak.
2016-01-07 02:30 AM
The Data Sheet (rev 9, Sep 2015) for the part makes no reference to this, just says 10 general purpose timers and has a block diagram showing TIM12
http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN775/PF216845
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00212417.pdf
2016-01-07 12:53 PM
Mayla, I checked the revision of the device and it says that is is revision 0x1003 (revision 1,2,3,X,or Y) and device identifier is 0x414.
As I understand it that means that this is in fact a STM32F101 device and not the STM32F100 device that is says on the package?I mean considering that the RM0041 is the manual for STM32F100 and RM0008 is the manual for STM32F101/2/3/5/7.This is very unfortunate, we just finished a PCB prototype using the information available in the datasheet for the STM32F100 and because of this error it does not work.I agree with clive1 that documentation is lacking in this area, had we known about this beforehand it would be easy to work around.I do however thank you for taking the time to respond to my question.Regards,Emil2016-01-18 08:24 AM
Hi emil,
If you refer tohttp://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00212417.pdf
that you should be using in your prototype, you will see in page 103 that the marking must contain B as internal code. So it has to be marked as: STM32F100RCT6B.If it is not the case, you have to check the issue with your distributor to get correct devices.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-01-18 10:04 AM
Ok, but where's the manual for the part he has? Is this a legitimate part?
The one you/I provided gives no information about other part numbering or details on fewer timers.2016-01-19 02:33 AM
Hi clive1,
Based on the DEV_ID value, RM0008 has to be used.But as I already said, the Distributor has to be contacted to get more details on how to do in such case (continue with these devices and look for manuals to be used or replace the with the correct STM32F100 devices).-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-01-19 08:22 AM
But the part quoted is a standard Tape-Reel product, should we understand that there is mismarked product from the factory, or counterfeit product in the channel?
2016-01-19 11:30 PM
It is neither a mismarked nor a counterfeit product.
With the agreement of Customers/Distributors requiring it, some STM32F103 devices were delivered in F100 packages.These Customers/Distributors are aware of the differences (F103 is more performant but some peripherals as timers may be missed there compared to F100).To conclude: the marking of STM32F100 devices must contain the internal code B. Otherwise, it has to be checked with distributor.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.