Fastest GPT and GPIO for Cortex-M4

显示  仅  | 搜索替代 

Fastest GPT and GPIO for Cortex-M4

267 次查看
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 项奖励
0 回复数