cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F100RCT6TR TIM12 issues

emil_eriksson4
Associate
Posted on January 06, 2016 at 18:39

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-around
12 REPLIES 12
Posted on January 20, 2016 at 14:23

Please consider making specific note of this in the Data Sheet, and any related documentation. 

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN775/PF216845

Once the parts leave the factory you have little control about where they end up. Engineers who have to support designs later in the life cycle may not be fully aware of this, and the supplied software and tools really don't differentiate this, as best I can tell.

I probably would have marked these devices as F103 parts and then wavier them into customers like that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Michele Galli
Associate
Posted on February 03, 2018 at 09:14

Hi Mayla,

    I think that we have the similar issue with STM32F100. We have develop a board with STM32F100, and this is the signature that ST-LINK utility shows:

    

Device: STM32F100xx Low/Medium density Value Line

DeviceID: 0x420

RevisionID: RevZ

Flash size: 64KBytes

    

Now we have some failure from DAC peripheral of that microcontroller during testing. ST-LINK utility shows, for that boards:

    

Device: STM32F10x Medium density

DeviceID: 0x410

RevisionID: RevY

Flash size: 64KBytes

    

Is that the STM32F101, please? Has STM32F101 the DAC peripheral?

    

Thank you,

Michele

henry.dick
Senior II
Posted on February 04, 2018 at 18:21

that's an interesting situation.

My nomination in this category is STM32FEBKC6T6,