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

Thread: qc of boards with teensy bootloader - bring RTC clock to a digital output

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    4

    qc of boards with teensy bootloader - bring RTC clock to a digital output

    I have a client using your teensy bootloader ICs on their hardware.

    Im writing QC procedures, and want their pcb stuffer to QC boards.
    I need to verify the correct operation of the 16MHz and 32K RTC clock the scopes that the suppliers will overload the Clks, so I wish to bring these clocks straight through onto a pair of spare pins and run a very basic QC sketch program for hardware verification.

    I just used the PWM function(analog write) to confirm correct frequency of the 16Mhz, divided by 32k of course to 488.25hz.

    Is there a convenient code example of how to bring the 32K RTC clock out, even if divide, preferably by an integer, so it can be probed?

    It should be known im a hardware guy thru & thru, minimal SW/FW ability...

    B.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    I believe I sent you an email reply with:

    Look at CLKOUTSEL in the SIM_SOPT2 register, and the ALT5 mux setting for PORTC_PCR3, pin PTC3 (or Arduino pin 9).
    To expand on that just a bit more, if you write to SIM_SOPT2 to select the 32 kHz clock, and put PTC3's mux into ALT5 mode, you should get a 32 kHz square wave on pin 9 (PTC3) directly from the on-chip oscillator.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    thanks Paul,
    ill give it a go now,
    B.

  4. #4
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    hi all,
    this sounds like writing in assembly many years ago for pic's..

    but how do i do this in the arduino enviroment? can anyone give me an example of code where control bits of configuration registers are setup?
    i had a dig, but i couldn't find any examples in the arduino IDE..


    B: confused:.

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,366
    As you asked for special feature, you may have to write it yourself

    I assume you wanted code for T3.x and not T4
    So, I checked kinetis.h, the k66 manual and some other core samples and
    Code:
     SIM_SOPT2 |=  SIM_SOPT2_CLKOUTSEL(5);
     CORE_PIN9_CONFIG  = PORT_PCR_MUX(5);

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Yes, that's pretty much it. But that 3 bit field needs to be cleared to zeros before the logical or.

    I ran this on a Teensy 3.5 and saw a 32.768 kHz square wave on pin 9.

    Code:
    void setup() {
      SIM_SOPT2 &= ~SIM_SOPT2_CLKOUTSEL(7);
      SIM_SOPT2 |=  SIM_SOPT2_CLKOUTSEL(5);
      CORE_PIN9_CONFIG  = PORT_PCR_MUX(5);
    }
    
    void loop() {
    }
    Click image for larger version. 

Name:	DSC_0640_web.jpg 
Views:	4 
Size:	123.1 KB 
ID:	17976

    Click image for larger version. 

Name:	file.png 
Views:	3 
Size:	28.2 KB 
ID:	17977

  7. #7
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    from the K64 Sub-Family Reference Manual, Rev. 3, July 2017, and considering im using the 144 pin LQFP device, not the 144 pin BGA:
    RTC_CLKOUT is available on PIN 1 (PTE0) in ALT 7 mode, and PIN 47 (PTE26) in ALT mode 6.

    a bit of bodging, since ard' pins are defined for a 144pin BGA, this worked spitting out 32K to LQFP pin 47.... note my amazing C skills to set RTC clock to not 1hz, but the orignal 32k..

    void setup() {
    // put your setup code here, to run once:

    // since a

    //SIM_SOPT2 |= SIM_SOPT2_CLKOUTSEL(5);
    SIM_SOPT2 = 0x00b0;

    CORE_PIN24_CONFIG = PORT_PCR_MUX(6); // comes out on LQFP pin 47... see pinlist...

    }

    void loop() {
    // put your main code here, to run repeatedly:


    }

    thanks all for your help!

Posting Permissions

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