stm32f0-counter

STM32F0 counter interrupt 說明/範例


更新記錄

item note
20171127 第一版

目錄


Counter Interrupt 範例說明

使用PA0產生TIM2計數

CubeMx說明

  • <1>設定PA0為TIM2_CH1

    [CubeMx]
  • <2>設定TIM2,SlaveMode/ Trigger Source

    [CubeMx]
  • <3>TIM2 Configuration

    [CubeMx] [CubeMx]
  • <4>程式增加內容如下

    [CubeMx] [CubeMx]

如何查看變數數值

  • <1>MDK5 debug 方式查看數值
    開啟debug(Start Debug Sessioin)
    新增Watch1變數count,即可查看

    [MDK5]
  • <2>STMStudio方式查看數值

    [STMStudio] [STMStudio] [STMStudio] [STMStudio]

register

  • TIM2
[TIM2] [TIM2 Register]
  • SMCR:Slave mode control register
    SMS(Slave mode selection) = 111 External Clock Mode
    TS(Trigger selection) = 101 Filtered Timer Inpupt 1(TI1FP1)

    [SMCR SMS] [SMCR SMS]
  • CCMR1

    [CCMR1]]

參考