Can attach 12 MHz clock to CTIMER2 but not to CTIMER1 on LPC55S66

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can attach 12 MHz clock to CTIMER2 but not to CTIMER1 on LPC55S66

619 Views
bob_nayar
Contributor I

If I run this code:

#define CTIMER CTIMER2 /* Timer 2 */
#define CTIMER_MAT_OUT kCTIMER_Match_1 /* Match output 1 */
#define CTIMER_CLK_FREQ CLOCK_GetCTimerClkFreq(2U)

CLOCK_AttachClk(kFRO_HF_to_CTIMER2);

CTIMER_GetDefaultConfig(&ctimer_config);

CTIMER_Init(CTIMER, &ctimer_config);

matchConfig.enableCounterReset = true;
matchConfig.enableCounterStop = false;
matchConfig.matchValue = CTIMER_CLK_FREQ / 2;
matchConfig.outControl = kCTIMER_Output_Toggle;
matchConfig.outPinInitState = true;
matchConfig.enableInterrupt = false;
CTIMER_SetupMatch(CTIMER, CTIMER_MAT_OUT, &matchConfig);
CTIMER_StartTimer(CTIMER);

sprintf(debug_message, "Clock Frequency is %d\n", CTIMER_CLK_FREQ);
USART_WriteBlocking(BENNU_USART, debug_message, (sizeof(debug_message) / sizeof(debug_message[0])) - 1);

I get the correct output "Clock Frequency is 96000000"

But if I change the first define to #define CTIMER CTIMER1 /* Timer 1 */

And change the Clock Attach statement to CLOCK_AttachClk(kFRO_HF_to_CTIMER1);

Then I get the output "Clock Frequency is 0"

And my output doesn't toggle.

Can you please let me know what's going on?

Thanks.

Labels (1)
0 Kudos
1 Reply

534 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Bob,

I suppose that if you use CTimer1, you should define the function as:

#define CTIMER_CLK_FREQ CLOCK_GetCTimerClkFreq(1U)

The "1U" means CTimer1, the "2U" means CTimer2, the parameter is CTimer index.

I do not test it, pls have a try.

BR

XiangJun Rong

0 Kudos