Hey guys! I started my foray in to ARM-land with an STM32F303CCT6 Cortex-M4 microcontroller. I'm not currently using the headers from ST. I have the MCU working fine and all the GPIO etc. stuff seems to work great.
I've been trying to get the advanced-control timer working (I need to drive a H-bridge) so center-aligned PWM would be great. I *think* I've understood how to configure the timer-module based on the ST appnote AN4013 (
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00042534.pdf chapter 2.5) and the MCU reference manual (
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00043574.pdf) but I'm unable to get a peep out of the timer module. Pins stay at GND level, no change at any point. What I *do* know is that the counter is running and I have configured the output pins as outputs with push-pull and have selected alternate function 6 for all of them which maps TIM1_CHx outputs to the pins (specified in MCU specific datasheet page 41:
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00058181.pdf). I have also enabled the "automatic output enable" which seems to be working because it enabled the "master output enable" bit. TIM1_CH1 is connected to PA8, CH2 to PA9, CH1N to PB13 and CH2N to PB0.
Here is the related code where you can see in which order I do things (based on the appnote):
http://paste.dy.fi/m2HHere are all the related register states from the debugger after configuration:
GPIOA_MODER: 0x48000000: 0xa9550000
GPIOA_OTYPER: 0x48000004: 0x00000000
GPIOA_OSPEEDR: 0x48000008: 0x0c000000
GPIOA_PUPDR: 0x4800000c: 0x65500000
Timer
TIM1_CR1: 0x40012c00: 0x000000b1
TIM1_CR2: 0x40012c04: 0x00000000
TIM1_SMCR: 0x40012c08: 0x00000000
TIM1_DIER: 0x40012c0c: 0x00000000
TIM1_SR: 0x40012c10: 0x00000007
TIM1_EGR: 0x40012c14: 0x00000000
TIM1_CCMR1: 0x40012c18: 0x00006868
TIM1_CCMR2: 0x40012c1c: 0x00000000
TIM1_CCER: 0x40012c20: 0x00000055
TIM1_CNT: 0x40012c24: 0x00000a57
TIM1_PSC: 0x40012c28: 0x00000000
TIM1_ARR: 0x40012c2c: 0x00000fff
TIM1_RCR: 0x40012c30: 0x00000000
TIM1_CCR1: 0x40012c34: 0x000000f0
TIM1_CCR2: 0x40012c38: 0x000000ff
TIM1_CCR3: 0x40012c3c: 0x00000000
TIM1_CCR4: 0x40012c40: 0x00000000
TIM1_BDTR: 0x40012c44: 0x0000c000
TIM1_DCR: 0x40012c48: 0x00000000
TIM1_DMAR: 0x40012c4c: 0x000000b1
TIM1_CCMR3: 0x40012c54: 0x00000000
TIM1_CCR5: 0x40012c58: 0x00000000
TIM1_CCR6: 0x40012c5c: 0x00000000
TIM1_OR: 0x40012c60: 0x00000000
I have gone through them several times now and verified that my defines seem to be correct. So I think I'm missing some part or I'm doing something in the wrong order. Too bad I can't see the OCxREF signal states with the debugger, that would tell me if the output compares are working or not... Any ideas what I'm doing wrong (or what I'm not doing what I'm supposed to)?
Edit: I have also enabled the clock for the related GPIO ports (A & B) and for the timer module.