2011-05-05 11:33 PM
Timer 8 not working STM32103RD?
2011-05-17 05:33 AM
The simulator? or a real part? I don't think I'd take the simulator as an authoritative reference.
BTW you need to modifiy your period : TIM_TimeBaseStructure.TIM_Period = 2000 - 1; // 0 .. 19992011-05-17 05:34 AM
The above code has been tested to generate 2 KHz (50/50) signal on PC.06 using TIM8, on an STM32F103ZE.
2011-05-17 05:34 AM
Both of them don't work.
Could you try making one project with timer 8 and see what happen?
If I replace the word 'TIM8'='TIM1' in my code that works, but 'TIM8' not.
Thanks. ^^
2011-05-17 05:34 AM
The STM32's (Medium Density) I have at hand only have 7 timers, the following code should be viable :
void RCC_Configuration(void) { // clock for GPIO RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); // clock for TIM8 RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE); } /**************************************************************************************/ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure ; // PC.06 TIM8_CH1 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); } /**************************************************************************************/ void TIM8_Configuration(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; TIM_TimeBaseStructure.TIM_Prescaler = 72 - 1; // 72 MHz / 72 = 1 MHz TIM_TimeBaseStructure.TIM_Period = 500 - 1; // 1 MHz / 500 = 2 KHz TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure); // Channel 1 configuration = PC.06 TIM8_CH1 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = (TIM_TimeBaseStructure.TIM_Period + 1) / 2; // 50% Duty TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC1Init(TIM8, &TIM_OCInitStructure); // turning on TIM8 and PWM outputs TIM_Cmd(TIM8, ENABLE); TIM_CtrlPWMOutputs(TIM8, ENABLE); } /**************************************************************************************/ int main(void) { RCC_Configuration(); GPIO_Configuration(); TIM8_Configuration(); while(1); }2011-05-17 05:34 AM
I try your code but I got the same result.
When I debug by keil. The TIM8_CNT not increase.
Your project run in real work?
2011-05-17 05:34 AM
Here my code.
Thanks for helping...
2011-05-17 05:34 AM
I try your code but I got the same result.
Maybe your part marking is wrong, and you don't have a high density part. The parts with 7 timers aren't going to work with TIM8. This code works with STM3210E board, with a STM32F103ZE. I didn't look at the registers, I stuck a scope on PC.06 and confirmed the frequency. Counter working. QED2011-05-17 05:34 AM
Thanks for your reply!
First the stm32f103rd is the high-density device.
The second is I don't have the STM3210E board, I have just debug with keiln and observe the register.
I will check by oscilloscope later.
2011-05-17 05:34 AM
First the stm32f103rd is the high-density device.
I am aware of that. That's why I suggested it is marked wrong (counterfeit, fake, remarked, whatever). If you enable TIM8 in the APB, and you can't read/write registers successfully, then the part does not have an operational TIM8.