QTMR of RT1064 counting external signal

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

QTMR of RT1064 counting external signal

跳至解决方案
1,144 次查看
Bosbessenbasje
Contributor I

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);
}

 

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
1,138 次查看
Bosbessenbasje
Contributor I

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);
}

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,139 次查看
Bosbessenbasje
Contributor I

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);
}

0 项奖励
回复