Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 4.0, F_BUS, F_BUS_ACTUAL, F_CPU, F_CPU_ACTUAL

  1. #1

    Teensy 4.0, F_BUS, F_BUS_ACTUAL, F_CPU, F_CPU_ACTUAL

    *

    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




  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,945
    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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Quote Originally Posted by LuisHS View Post
    Can I replace in my sources F_CPU with F_CPU_ACTUAL, and F_BUS with F_BUS_ACTUAL?
    Short answer: Yes, or probably yes, if your source code uses these in an expression or equation (not a #if or #ifdef way). Of course with the caveat this is blind guess, not seeing your source code.

    Longer answer is here:

    https://forum.pjrc.com/threads/57236...l=1#post212642

  4. #4
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •