I want to count an external signal and have the following code, but the external signal is not counted. When I change the clock source to the default, the timer is running just fine. But using the external signal to clock the counter does not. I must be missing something trivial here...
CLOCK_EnableClock(kCLOCK_Iomuxc);
CLOCK_EnableClock(kCLOCK_Xbar1);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_14_XBAR1_IN24, 0U); // J15-37
IOMUXC_GPR->GPR6 = ((IOMUXC_GPR->GPR6 & (~(IOMUXC_GPR_GPR6_QTIMER4_TRM0_INPUT_SEL_MASK))) | IOMUXC_GPR_GPR6_QTIMER4_TRM0_INPUT_SEL(0x01U));
XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputIomuxXbarIn24, kXBARA1_OutputQtimer4Tmr0Input);
qtmr_config_t qtmrConfig;
QTMR_GetDefaultConfig(&qtmrConfig);
qtmrConfig.primarySource = kQTMR_ClockCounter0InputPin;
QTMR_Init(TMR4, kQTMR_Channel_0, &qtmrConfig);
QTMR_StartTimer(TMR4, kQTMR_Channel_0, kQTMR_PriSrcRiseEdge);
static volatile uint16 value;
while (true)
{
value = QTMR_GetCurrentTimerCount(TMR4, kQTMR_Channel_0);
}
解決済! 解決策の投稿を見る。
I got it to work, it seems to be a problem with my demoboard on that pin, the following code works just as expected:
CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B1_02_QTIMER3_TIMER2, 0U); // J15-30
IOMUXC_GPR->GPR6 = ((IOMUXC_GPR->GPR6 & (~(IOMUXC_GPR_GPR6_QTIMER3_TRM2_INPUT_SEL_MASK))) | IOMUXC_GPR_GPR6_QTIMER3_TRM2_INPUT_SEL(0x00U));
qtmr_config_t qtmrConfig;
QTMR_GetDefaultConfig(&qtmrConfig);
qtmrConfig.primarySource = kQTMR_ClockCounter2InputPin;
QTMR_Init(TMR3, kQTMR_Channel_2, &qtmrConfig);
QTMR_StartTimer(TMR3, kQTMR_Channel_2, kQTMR_PriSrcRiseEdge);
static volatile uint16 value;
while (true)
{
value = QTMR_GetCurrentTimerCount(TMR3, kQTMR_Channel_2);
}
I got it to work, it seems to be a problem with my demoboard on that pin, the following code works just as expected:
CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B1_02_QTIMER3_TIMER2, 0U); // J15-30
IOMUXC_GPR->GPR6 = ((IOMUXC_GPR->GPR6 & (~(IOMUXC_GPR_GPR6_QTIMER3_TRM2_INPUT_SEL_MASK))) | IOMUXC_GPR_GPR6_QTIMER3_TRM2_INPUT_SEL(0x00U));
qtmr_config_t qtmrConfig;
QTMR_GetDefaultConfig(&qtmrConfig);
qtmrConfig.primarySource = kQTMR_ClockCounter2InputPin;
QTMR_Init(TMR3, kQTMR_Channel_2, &qtmrConfig);
QTMR_StartTimer(TMR3, kQTMR_Channel_2, kQTMR_PriSrcRiseEdge);
static volatile uint16 value;
while (true)
{
value = QTMR_GetCurrentTimerCount(TMR3, kQTMR_Channel_2);
}