Блин, Досикус, который раз убеждаюсь в Вашей правоте по поводу HAL.
Как только настроил всё ручками - проблема пропала...
[HTML]
/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx.h"
/** @addtogroup STM32F0_Snippets
* @{
*/
/* Define the Timer to be configured */
#define TIMx TIM1
#define TIMx_BASE TIM1_BASE
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void ConfigureGPIO(void);
void ConfigureTIMxAsOutputCompare(void);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
ConfigureGPIO();
ConfigureTIMxAsOutputCompare();
GPIOC-›BSRR = 1‹‹9; /* switch on green led */
while (1)
{
;//__WFI();
}
}
/**
* @brief This function enables the peripheral clocks on GPIO port C,
* configures GPIO PC9 in output mode for the Green LED pin,
* configures GPIO PC8 in output mode for the orange LED pin,
* @param None
* @retval None
*/
__INLINE void ConfigureGPIO(void)
{
/* (1) Enable the peripheral clock of GPIOC */
/* (2) Select output mode (01) on GPIOC pin 8 and 9 */
RCC-›AHBENR |= RCC_AHBENR_GPIOCEN; /* (1) */
GPIOC-›MODER = (GPIOC-›MODER & ~(GPIO_MODER_MODER8|GPIO_MODER_MODER9)) \
| (GPIO_MODER_MODER8_0|GPIO_MODER_MODER9_0); /* (2) */
}
/**
* @brief This function configures the TIMx as output compare
* and enables the peripheral clock on TIMx and on GPIOA.
* It configures GPIO PA8 as Alternate function for TIM1_CH1
* To use another timer, channel or GPIO, the RCC and GPIO configuration
* must be adapted according to the datasheet.
* In case of other timer, the interrupt sub-routine must also be renamed
* with the right handler and the NVIC configured correctly.
* @param None
* @retval None
*/
__INLINE void ConfigureTIMxAsOutputCompare(void)
{
RCC-›APB2ENR |= RCC_APB2ENR_TIM1EN | RCC_APB2ENR_TIM15EN;
RCC-›AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
GPIOA-›MODER = (GPIOA-›MODER & ~(GPIO_MODER_MODER7)) | (GPIO_MODER_MODER7_1);
GPIOA-›MODER = (GPIOA-›MODER & ~(GPIO_MODER_MODER
![Горд собой](images/smilies/icon_dovl.gif)
) | (GPIO_MODER_MODER8_1);
GPIOA-›MODER = (GPIOA-›MODER & ~(GPIO_MODER_MODER9)) | (GPIO_MODER_MODER9_1);
GPIOB-›MODER = (GPIOB-›MODER & ~(GPIO_MODER_MODER0)) | (GPIO_MODER_MODER0_1);
//PA7
GPIOA-›AFR[0] |= 0x02‹‹28;
//PA8
GPIOA-›AFR[1] |= 0x02; /* (4) */
//PA9
GPIOA-›AFR[1] |= 0x02 ‹‹ 4;
//PB0
GPIOB-›AFR[0] |= 0x02; /* (4) */
//TIMx-›PSC |= 3; /* (1) */
TIMx-›ARR = 12000 - 1; /* (2) */
TIMx-›CCR1 = 6000 - 1; /* (3) */
TIMx-›CCR2 = 6000 - 1; /* (3) */
TIMx-›CCMR1 |= TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_1;
TIMx-›CCMR1 |= TIM_CCMR1_OC2M_0 | TIM_CCMR1_OC2M_1;
TIMx-›CCER |= TIM_CCER_CC1E | TIM_CCER_CC1NE;
TIMx-›CCER |= TIM_CCER_CC2E | TIM_CCER_CC2NE;
TIMx-›BDTR |= TIM_BDTR_MOE | TIM_BDTR_OSSR; /* (6) */
TIMx-›CR1 |= TIM_CR1_CEN; /* (7) */
GPIOA-›MODER = (GPIOA-›MODER & ~(GPIO_MODER_MODER2)) | (GPIO_MODER_MODER2_1);
//PA2
GPIOA-›AFR[0] |= 0x02‹‹8;
//Automatic Reload Register
TIM15-›ARR = 200;
TIM15-›CCR1 = 100;
//ARPE ENABLE
TIM15-›CR1 |= 0x80;
//TRG0 on update enable
TIM15-›CR2 |= 0x20;
//Repetion counter
TIM15-›RCR = 0x00;
TIM15-›CCER |= TIM_CCER_CC1E ;
TIM15-›BDTR |= TIM_BDTR_MOE | TIM_BDTR_OSSR;
//Start the timer
//TIM15-›CR1 |= 1;
TIM15-›CR1 |= TIM_CR1_CEN;
}
[/HTML]