Fastest GPT and GPIO for Cortex-M4

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

Fastest GPT and GPIO for Cortex-M4

Contributor I

What's the fastest timer and gpio-toggle I should be able to set on the M4 on an Imx8MM? 

The fastest seems to be 704 khz.  In my ISR, I change the state.  The fastest I can toggle my gpio seems to be about 460 ns.  That seems slow.  The core clock states to be 4Mhz.  Is there a dedicated clock that controls gpio?

My timer init is below:

gpt_config_t gptConfig;
uint32_t gptFreq;

CLOCK_SetRootMux(kCLOCK_RootGpt1, kCLOCK_GptRootmuxSysPll1Div2); /* Set GPT1 source to SYSTEM PLL1 DIV2 400MHZ */
CLOCK_SetRootDivider(kCLOCK_RootGpt1, 1U, 4U); /* Set root clock to 400MHZ / 4 = 100MHZ */


/* Initialize GPT module */
GPT_Init(GPT1, &gptConfig);

/* Divide GPT clock source frequency by 3 inside GPT module */
GPT_SetClockDivider(GPT1, 3);

/* Get GPT clock frequency */
//100,000,000 Mhz

/* GPT frequency is divided by 3 inside module */
gptFreq /= 3;
PRINTF("%s gptFreq %d.\r\n", __func__, gptFreq);
// 500 us
gptFreq = USEC_TO_COUNT(250, gptFreq); /* FreeRTOS tick is 1 kHz */

//PRINTF("Starting %s %d.\r\n", __func__, gptFreq);

/* Set both GPT modules to 1 second duration */
GPT_SetOutputCompareValue(GPT1, kGPT_OutputCompare_Channel1, gptFreq);

/* Enable GPT Output Compare1 interrupt */
GPT_EnableInterrupts(GPT1, kGPT_OutputCompare1InterruptEnable);

/* Enable at the Interrupt */

/* Start Timer */
PRINTF("\r\nStarting GPT timer ...");

0 Kudos
0 Replies