General Purpose Timer Clock Source

Status
Not open for further replies.

hsem

New member
Hi, does anyone have any insight on how to change the clock source on the GPT to be higher than 24MHz? I see on page 2961 of the manual that I should be able to change the input to ipg_clk_highfreq but this still seems to run at 24MHz. From table 14-5 (page 1031) in the manual is seems to suggest that the IPG_CLK_ROOT should be able to run up to 150MHz but I am unsure how to change VDD_SOC_IN . Is this something that is fixed or can be changed?

What I am trying to do is capture the input time of an external signal to the highest precision possible, nanoseconds if possible. The input signal is MHz rates. I previously had an interrupt on the pin to save ARM_DWT_CYCCNT but I would prefer to do this in hardware to leave the processor free.

Does anyone have any insights or better ways to achieve this? Would a different timer be better suited?

I'm quite new to this so apologies if anything isn't clear!
 
The IGP is already running with 150MHz.
Not sure about the GPT frequency (would have to take a look..)
The clock diagram on Page1016 (Rev Manual V2) say it can be switched between IGP and 24MHz with CSCMR1[PRECLK_CLK_SEL].
Perhaps simply look what the current value is.
 
Thank you for the reply! Looks like the MUX was taking the OSC clock (24MHz) instead of the IPG clock (150MHz). The default for CSCMR1[PRECLK_CLK_SEL] in the manual says that it should take the IPG clock but perhaps this is changed in the T4.1 setup.
 
Maybe yes.
Or, perhaps the manual is wrong about the default. There are several things with wrong info... i.e. the all the PFD had wrong values at least in rev 1.

Don't trust the printed defaults.
 
Thank you for the reply! Looks like the MUX was taking the OSC clock (24MHz) instead of the IPG clock (150MHz). The default for CSCMR1[PRECLK_CLK_SEL] in the manual says that it should take the IPG clock but perhaps this is changed in the T4.1 setup.

The T4 configures the GPT and PIT to clock at 24mhz, if you configure for 150mhz it will break the interval timer (PIT). here is example of GPT running at 150mhz
https://github.com/manitou48/teensy4/blob/master/gpsgpt.ino
there are other examples in that repository.
 
I see no problem setting the CSCMR1[PRECLK_CLK_SEL] to be ipg_clk_root and using interval timers. As the clock is 6.25 times faster, the timing needs to be adjusted but still works. For example

Code:
IntervalTimer myTimer;
uint32_t on_off;

void pulse() {
  if (on_off) {
    digitalWrite(13, HIGH);
    on_off = 0;
  }
  else {
    digitalWrite(13, LOW);
    on_off = 1;
  }
  
}

void setup() {
  
  // Change peripheral clock source from OSC to ipg_clk_root
  // Page 1057
  CCM_CSCMR1 &= ~64;
  
  // LED output and timer
  pinMode(13, OUTPUT);
  myTimer.begin(pulse, 6250000);
}

void loop() {

}

will set the GPT clock to 150MHz and also flash the LED on T4.1 using an interval timer.
 
Status
Not open for further replies.
Back
Top