2019-09-05 04:36 PM
I'm attempting to output a 50% duty cycle clock signal on Port C bit 7.
I running on a STM32F407
I have verified that that output is working when set the pin as function 0 and toggled.
Using function 2 when associated with the timer 3 channel 2
I have also verified with a debugger that the timer is running.
I am using the following code - can someone point out my error.
I tried the output mode at PWM and as Toggle - neither work.
I've read the 407 manual and AN4776 (App Note on timers) multiple times but no help there.
Thanks in advance for your help
<code>
void SCCB_Init(void)
{
Config_STM_Pin(GPIOC, 7, 2, H_GPIO_Output, H_GPIO_Output_PushPull, SlewRate_Medium, No_Pull_Up_or_Down);
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // turn clock on uses clock at 42 mhz
Wait_Block_MicroSec(500);
TIM3->ARR = 4200;
TIM3->SR = 0; // reset done flag
TIM3->CCMR1 = TIM_CCMR1_OC2M_0 | TIM_CCMR1_OC2M_1;
TIM3->CCER = TIM_CCER_CC1E;
TIM3->CCR2 = TIM3->ARR / 2;
TIM3->CR1 = TIM_CR1_CEN;
}
</code>
2019-09-05 05:21 PM
Make sure GPIOC clock is enabled, make sure the AF setting correct for TIM3_CH2
Check registers in debugger, make sure TIM is ticking
2019-09-05 05:22 PM
Posted code looks good.
Read out and check/post the relevant GPIO and timer registers' content.
JW