2017-09-23 04:19 AM
Hello! I try to program stm32f103c8t6 TIM1 in output compare mode (connecting it to PA8 pin).But PA8 doesn`t have any signal.In Keil`s debugger the timer running.
&sharpinclude <stm32f10x.h>
void main(void){RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; GPIOB ->CRH = GPIO_CRH_CNF13_1 | GPIO_CRH_MODE13; GPIOA->CRH = GPIO_CRH_CNF8_1 | GPIO_CRH_MODE8; TIM1->CCMR1 = TIM_CCMR1_OC1PE|TIM_CCMR1_OC1M_0 |TIM_CCMR1_OC1M_1 ; TIM1->CCER=TIM_CCER_CC1E; TIM1->ARR = 0x0FFF; TIM1->PSC = 0x000A; TIM1->CCR3 = 0x0000; TIM1->CR1 |= TIM_CR1_CEN|TIM_CR1_ARPE; while(1) { } }P.S. Width TIM2 this code running well.
Thank for answer!
#stm32f103-tim1Solved! Go to Solution.
2017-09-28 09:35 AM
Thanks a lot for your help and answers!!! I didn`t write TIM_BDTR_MOE flag into BDTR register
.
2017-09-24 12:55 AM
Hello!
PA8 is not by defaul connected internaly to TIM1.
Alternate Function IO functionality must used to assign PA8 as TIM1_OC.
AFIO registers described in RM.
Also in RCC_APB2ENR register the AFIO EN bit must be set before configure AFIO registers.
Regards
vf
2017-09-24 05:02 AM
The advanced timers (TIM1 and TIM8) need also TIMx_BDTR.MOE to be set, for outputs to work.
JW
2017-09-28 09:35 AM
Thanks a lot for your help and answers!!! I didn`t write TIM_BDTR_MOE flag into BDTR register
.