微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > k60输入捕获采到的频率不对

k60输入捕获采到的频率不对

时间:10-02 整理:3721RD 点击:

我用kinetis k60做PWM输入捕获的实验,我设的PA6输出PWM输出是100hz,短接PA6和PA8,在PA8采集到的是6Hz,这个结果是怎么回事?(用逻辑分析仪采到PA6上是100Hz).谁能告诉一下?附上代码:
static uint32_t InputCaptureValue;
static void FTM1_ISR(void)
{
    uint32_t clock;
    InputCaptureValue = FTM_GetChlCounter(HW_FTM1, HW_FTM_CH0);
    clock = GetClock(kBusClock);
    //CLOCK_GetClockFrequency(kBusClock,&clock);
    FTM_SetMoudleCounter(HW_FTM1, 0);
    InputCaptureValue = (clock/16/InputCaptureValue);
}
DelayInit();
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    GPIO_QuickInit(HW_GPIOE, 7, kGPIO_Mode_OPP); /* LED */
    printf("ftm intput capture test, pwm will be generated on PA06 and input pin: PA08\r\n");
    FTM_PWM_QuickInit(FTM0_CH4_PA07, kPWM_EdgeAligned, 100);//设置频率为100
//输入捕获部分
    FTM_IC_QuickInit(FTM1_CH0_PA08, kFTM_ClockDiv16);
    FTM_IC_SetTriggerMode(HW_FTM1, HW_FTM_CH0, kFTM_IC_FallingEdge);
    FTM_CallbackInstall(HW_FTM1, FTM1_ISR);
    FTM_ITDMAConfig(HW_FTM1, kFTM_IT_CH0, true);
    while(1)
    {
        printf("Frequency:%6dHz\r", InputCaptureValue);
        GPIO_ToggleBit(HW_GPIOE, 7);
        DelayMs(500);
    }


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top