Teensy 4.0, F_BUS, F_BUS_ACTUAL, F_CPU, F_CPU_ACTUAL

Status
Not open for further replies.

LuisHS

Well-known member
*

Hello

To port some sources that originally work in Teensy 3.6, some values, such as timers, are calculated based on the constants F_CPU and F_BUS.

I see that in Teensy 4, there are no such constants, although looking for I find F_CPU_ACTUAL and F_BUS_ACTUAL. I have made a Debug with these constants, and I get 600Mhz for F_CPU_ACTUAL and 150Mhz for F_BUS_ACTUAL.

Can I replace in my sources F_CPU with F_CPU_ACTUAL, and F_BUS with F_BUS_ACTUAL?, Apparently they are equivalent, F_CPU indicates the frequency of the oscillator, 600Mhz in the RT1062, and 150Mhz for the bus, are the same data that I can see when editing some example in the MCUXpresso SDK, although there 150Mhz is the value of IPG_CLK_ROOT.

I enclose screenshots.

regards


r82E7kx.jpg

6kdnIIj.jpg
 
Those are valid and real values - but may not always relate to the clocks used by the timers.

The F_CPU clock is independent of other usable clocks on T4. Of course the RefMan has real details - there are examples in the T4_Beta thread where some specific timers were setup for working examples and ref to what clocks may be used.

If you don't find those posts either present or helpful and get stuck, asking a question as to the desired usage situation and those folks may help with details.
 
Thanks Paul and Defragster.

The source uses F_BUS to calculate a timer, and F_CPU to calculate the frequency of updating images on LED panels using the Startmatrix library.

This is the part of the sources where F_CPU and F_BUS are used:

// hardware-specific definitions
// prescale of 1 is F_BUS / 2
#define LATCH_TIMER_PRESCALE 0x01
#define TIMER_FREQUENCY (F_BUS / 2)
#define NS_TO_TICKS (X) (uint32_t) (TIMER_FREQUENCY * ((X) / 1000000000.0))
#define LATCH_TIMER_PULSE_WIDTH_TICKS NS_TO_TICKS (LATCH_TIMER_PULSE_WIDTH_NS)
#define TICKS_PER_ROW (TIMER_FREQUENCY / refreshRate / matrixRowsPerFrame)
#define IDEAL_MSB_BLOCK_TICKS (TICKS_PER_ROW / 2)
#define MIN_BLOCK_PERIOD_NS (LATCH_TO_CLK_DELAY_NS + ((PANEL_32_PIXELDATA_TRANSFER_MAXIMUM_NS * PIXELS_PER_LATCH) / 32))
#define MIN_BLOCK_PERIOD_TICKS NS_TO_TICKS (MIN_BLOCK_PERIOD_NS)
#define PIXELS_PER_LATCH ((matrixWidth * matrixHeight) / matrixPanelHeight)

// measured <3400ns to transfer 32 pixels at 96MHz, <6600ns to transfer 32 pixels at 48MHz
#define PANEL_32_PIXELDATA_TRANSFER_MAXIMUM_NS (uint32_t) ((3400 * 96000000.0) / F_CPU)
 
Status
Not open for further replies.
Back
Top