Usage of EXT_CLK1 for GPT1 on IMX8MN M7

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

Usage of EXT_CLK1 for GPT1 on IMX8MN M7

232 Views
BartholomeusDias
Contributor I

Hi,

I want to use the GPT1 timer on the M7 side of a IMX8MN in a FreeRTOS program. I do not need it on the Linux side. The M7 is booted by u-boot.
GPT1 needs to be clocked with an external clock, and I need to use the two capture inputs to count time in between some events.

I have this in u-boot:

RDC_PDAP RDC_PDAP_GPT1  PDAP_D1_ACCESS 0x0 0x0


And this in my M7 program:

 periphConfig.periph = kRDC_Periph_GPT1;
 RDC_SetPeriphAccessConfig(RDC, &periphConfig);


Because I want to count with an external 48MHz clock, I did not use the GPT1_CLK input pin because of clock speed limits (1/4 speed rule for ipg_clk). Instead I changed the root clock of GPT to use EXT_CLK1 so ipg_clk is the same:

CLOCK_SetRootMux(kCLOCK_RootGpt1, kCLOCK_GptRootmuxExtClk123);


Ignoring the capture lines for now, I wrote a simple test program on the M7 side that just prints the (current - previous) count value every second, so I would expect to see a number close to 48000000.

This all works fine, as long as the clock signal is actually present on the pin. The problem is, that the presence of the 48MHz clock signal is not always guaranteed in my system as it is generated externally.
Especially during boot time, the clock will not yet be available.

When I boot the board without the 48MHz clock, the Linux boot procedure stalls midway.
If I enable the clock during boot, Linux boot proceeds.
If I boot the board using the internal 24MHz clock as input for GPT1, and switch to EXT_CLK1 in the M7 code after some time when the 48MHz clock is present, it works.
When I disable the external 48MHz clock during normal operation (so when counting works), both Linux and M7 stall completely.

It sound similar to what is described here although the use case is different:
https://community.nxp.com/t5/i-MX-Processors/External-clock-that-provide-root-clock-for-SAI3-and-SPD... 

Would you have a clue as to why the board freezes when this clock disappears? Does it freeze the internal busses or something like that?
Is there a way to prevent clock presence dependency for both OS's on GPT1?

Thanks in advance!

Labels (1)
0 Kudos
0 Replies