MIMXRT595 board, Fusion-F1 (Xtensa)- can't run interrupts for a CTimer

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

MIMXRT595 board, Fusion-F1 (Xtensa)- can't run interrupts for a CTimer

565 Views
rttPromt
Contributor I

I want to run CTimer 2- for example in the match mode. And can't get interrupts when matched.

 

static ctimer_callback_t ctimer_callback[] = {timer3_interrupt_handler};
void timer3_interrupt_handler(uint32_t flags)
{
	static int tst_cnt = 0;
	tst_cnt++;
	Logger::instance().log("timer3_interrupt_handler %d \r\n", tst_cnt);
}
void init_timer ()
{
	CLOCK_AttachClk(kMAIN_CLK_to_CTIMER2);

	// Initialize CTIMER2 with the default configuration
	ctimer_config_t config;
	CTIMER_GetDefaultConfig(&config);
	CTIMER_Init(CTIMER2, &config);

	// Initialize match config
	ctimer_match_config_t matchConfig;
	matchConfig.enableCounterReset = true; // Match will reset the counter
	matchConfig.enableCounterStop  = true; // Match will stop the counter
	matchConfig.matchValue         = 10 * CLOCK_GetCtimerClkFreq(2); 
	matchConfig.outControl         = kCTIMER_Output_NoAction; // No action is taken upon match
	matchConfig.outPinInitState    = true; // Initial value of the output
	matchConfig.enableInterrupt    = true; // Generate interrupt upon match

	 CTIMER_RegisterCallBack(CTIMER2, &ctimer_callback[0], kCTIMER_SingleCallback);
	// Setup the CTIMER to generate an interrupt upon match
	CTIMER_SetupMatch(CTIMER2, kCTIMER_Match_2, &matchConfig);

	// Start CTIMER3
	CTIMER_StartTimer(CTIMER2);
}

 

And it doesn't call interrupt handler. May be first we should enable global interrupts? Or something else?

Tags (1)
0 Kudos
3 Replies

534 Views
rttPromt
Contributor I

Hi!

This example doesn't work. I tested it. And I wrote message due to it doesn't work. Check it on your side on  the F1 CPU.

0 Kudos

528 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please refer attached <main_dsp.c> file about CTIMER2 interrupt example.

There with included driver files & some setting for project:

Hui_Ma_0-1667984303689.jpeg

Hui_Ma_1-1667984341550.jpegHui_Ma_2-1667984354708.png

More detailed info, please refer SDK package provided <Getting Started with Xplorer for EVK-MIMXRT685> Chapter 6.2.3 Interrupts.

Wish it helps.

0 Kudos

541 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

The MCUXpresso SDK provided [ctimer_match_interrupt_example] with below ctimer callback table:

/* Array of function pointers for callback for each channel */
ctimer_callback_t ctimer_callback_table[] = {
ctimer_match0_callback, ctimer_match1_callback, NULL, NULL, NULL, NULL, NULL, NULL};

Please refer above code to place ctimer2 callback function at correct position.

More detailed  info, please refer MCUXpresso SDK ctimer match interrupt example.

Wish it helps.

Mike

0 Kudos