Quellcode durchsuchen

Merge pull request #15 from FrankBoesing/144MHz-only

+Overclock 144 MHz only
teensy4-core
Paul Stoffregen vor 10 Jahren
Ursprung
Commit
ce59be18a3
7 geänderte Dateien mit 43 neuen und 10 gelöschten Zeilen
  1. +7
    -0
      README.md
  2. +3
    -1
      teensy3/core_pins.h
  3. +19
    -4
      teensy3/mk20dx128.c
  4. +4
    -1
      teensy3/mk20dx128.h
  5. +4
    -2
      teensy3/pins_teensy.c
  6. +3
    -1
      teensy3/usb_seremu.c
  7. +3
    -1
      teensy3/usb_serial.c

+ 7
- 0
README.md Datei anzeigen



http://www.pjrc.com/teensy/td_download.html http://www.pjrc.com/teensy/td_download.html


This version implements overclock to 120MHz, 144MHz and 168MHz.

Howto:
1. Overwrite Arduino\hardware\teensy\boards.txt with this version
2. Overwrite all in core/teensy3 with this version







+ 3
- 1
teensy3/core_pins.h Datei anzeigen

static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused)); static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
static inline void delayMicroseconds(uint32_t usec) static inline void delayMicroseconds(uint32_t usec)
{ {
#if F_CPU == 96000000
#if F_CPU == 144000000
uint32_t n = usec * 48;
#elif F_CPU == 96000000
uint32_t n = usec << 5; uint32_t n = usec << 5;
#elif F_CPU == 48000000 #elif F_CPU == 48000000
uint32_t n = usec << 4; uint32_t n = usec << 4;

+ 19
- 4
teensy3/mk20dx128.c Datei anzeigen

extern unsigned long _estack; extern unsigned long _estack;
//extern void __init_array_start(void); //extern void __init_array_start(void);
//extern void __init_array_end(void); //extern void __init_array_end(void);



extern int main (void); extern int main (void);
void ResetHandler(void); void ResetHandler(void);
void _init_Teensyduino_internal_(void); void _init_Teensyduino_internal_(void);
// now we're in FBE mode // now we're in FBE mode
// config PLL input for 16 MHz Crystal / 4 = 4 MHz // config PLL input for 16 MHz Crystal / 4 = 4 MHz
MCG_C5 = MCG_C5_PRDIV0(3); MCG_C5 = MCG_C5_PRDIV0(3);
// config PLL for 96 MHz output
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(0);
#if F_CPU == 144000000
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(12); // config PLL for 144 MHz output
#else
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(0); // config PLL for 96 MHz output
#endif
// wait for PLL to start using xtal as its input // wait for PLL to start using xtal as its input
while (!(MCG_S & MCG_S_PLLST)) ; while (!(MCG_S & MCG_S_PLLST)) ;
// wait for PLL to lock // wait for PLL to lock
while (!(MCG_S & MCG_S_LOCK0)) ; while (!(MCG_S & MCG_S_LOCK0)) ;
// now we're in PBE mode // now we're in PBE mode
#if F_CPU == 96000000

#if F_CPU == 144000000
// config divisors: 144 MHz core, 48 MHz bus, 24 MHz flash
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(2) | SIM_CLKDIV1_OUTDIV4(5);
#elif F_CPU == 96000000
// config divisors: 96 MHz core, 48 MHz bus, 24 MHz flash // config divisors: 96 MHz core, 48 MHz bus, 24 MHz flash
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(3); SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(3);
#elif F_CPU == 48000000 #elif F_CPU == 48000000
// config divisors: 24 MHz core, 24 MHz bus, 24 MHz flash // config divisors: 24 MHz core, 24 MHz bus, 24 MHz flash
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(3) | SIM_CLKDIV1_OUTDIV2(3) | SIM_CLKDIV1_OUTDIV4(3); SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(3) | SIM_CLKDIV1_OUTDIV2(3) | SIM_CLKDIV1_OUTDIV4(3);
#else #else
#error "Error, F_CPU must be 96000000, 48000000, or 24000000"
#error "Error, F_CPU must be 144000000, 96000000, 48000000, or 24000000"
#endif #endif
// switch to PLL as clock source, FLL input = 16 MHz / 512 // switch to PLL as clock source, FLL input = 16 MHz / 512
MCG_C1 = MCG_C1_CLKS(0) | MCG_C1_FRDIV(4); MCG_C1 = MCG_C1_CLKS(0) | MCG_C1_FRDIV(4);
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST(3)) ; while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST(3)) ;
// now we're in PEE mode // now we're in PEE mode
// configure USB for 48 MHz clock // configure USB for 48 MHz clock
#if F_CPU == 144000000
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(2); // USB = 144 MHz PLL / 3
#else
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(1); // USB = 96 MHz PLL / 2 SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(1); // USB = 96 MHz PLL / 2
#endif
// USB uses PLL clock, trace is CPU clock, CLKOUT=OSCERCLK0 // USB uses PLL clock, trace is CPU clock, CLKOUT=OSCERCLK0
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6); SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6);



+ 4
- 1
teensy3/mk20dx128.h Datei anzeigen

//#define F_BUS 24000000 //#define F_BUS 24000000
//#define F_MEM 24000000 //#define F_MEM 24000000


#if (F_CPU == 96000000)
#if (F_CPU == 144000000)
#define F_BUS 48000000
#define F_MEM 24000000
#elif (F_CPU == 96000000)
#define F_BUS 48000000 #define F_BUS 48000000
#define F_MEM 24000000 #define F_MEM 24000000
#elif (F_CPU == 48000000) #elif (F_CPU == 48000000)

+ 4
- 2
teensy3/pins_teensy.c Datei anzeigen

#if F_BUS == 48000000 #if F_BUS == 48000000
#define DEFAULT_FTM_MOD (49152 - 1) #define DEFAULT_FTM_MOD (49152 - 1)
#define DEFAULT_FTM_PRESCALE 1 #define DEFAULT_FTM_PRESCALE 1
#else
#elif F_BUS == 24000000
#define DEFAULT_FTM_MOD (49152 - 1) #define DEFAULT_FTM_MOD (49152 - 1)
#define DEFAULT_FTM_PRESCALE 0 #define DEFAULT_FTM_PRESCALE 0
#endif #endif
} }
} }


#if F_CPU == 96000000
#if F_CPU == 144000000
#define PULSEIN_LOOPS_PER_USEC 21
#elif F_CPU == 96000000
#define PULSEIN_LOOPS_PER_USEC 14 #define PULSEIN_LOOPS_PER_USEC 14
#elif F_CPU == 48000000 #elif F_CPU == 48000000
#define PULSEIN_LOOPS_PER_USEC 7 #define PULSEIN_LOOPS_PER_USEC 7

+ 3
- 1
teensy3/usb_seremu.c Datei anzeigen

// software. If it's too long, we stall the user's program when no software is running. // software. If it's too long, we stall the user's program when no software is running.
#define TX_TIMEOUT_MSEC 30 #define TX_TIMEOUT_MSEC 30


#if F_CPU == 96000000
#if F_CPU == 144000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932)
#elif F_CPU == 96000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596) #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#elif F_CPU == 48000000 #elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428) #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)

+ 3
- 1
teensy3/usb_serial.c Datei anzeigen

// software. If it's too long, we stall the user's program when no software is running. // software. If it's too long, we stall the user's program when no software is running.
#define TX_TIMEOUT_MSEC 70 #define TX_TIMEOUT_MSEC 70


#if F_CPU == 96000000
#if F_CPU == 144000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932)
#elif F_CPU == 96000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596) #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#elif F_CPU == 48000000 #elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428) #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)

Laden…
Abbrechen
Speichern