Преглед изворни кода

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

+Overclock 144 MHz only
teensy4-core
Paul Stoffregen пре 10 година
родитељ
комит
ce59be18a3
7 измењених фајлова са 43 додато и 10 уклоњено
  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 Прегледај датотеку

@@ -4,5 +4,12 @@ The latest stable version of Teensy's core library is always available in the Te

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 Прегледај датотеку

@@ -770,7 +770,9 @@ uint32_t micros(void);
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
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;
#elif F_CPU == 48000000
uint32_t n = usec << 4;

+ 19
- 4
teensy3/mk20dx128.c Прегледај датотеку

@@ -40,6 +40,9 @@ extern unsigned long _ebss;
extern unsigned long _estack;
//extern void __init_array_start(void);
//extern void __init_array_end(void);



extern int main (void);
void ResetHandler(void);
void _init_Teensyduino_internal_(void);
@@ -413,14 +416,22 @@ void ResetHandler(void)
// now we're in FBE mode
// config PLL input for 16 MHz Crystal / 4 = 4 MHz
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
while (!(MCG_S & MCG_S_PLLST)) ;
// wait for PLL to lock
while (!(MCG_S & MCG_S_LOCK0)) ;
// 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
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(3);
#elif F_CPU == 48000000
@@ -430,7 +441,7 @@ void ResetHandler(void)
// 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);
#else
#error "Error, F_CPU must be 96000000, 48000000, or 24000000"
#error "Error, F_CPU must be 144000000, 96000000, 48000000, or 24000000"
#endif
// switch to PLL as clock source, FLL input = 16 MHz / 512
MCG_C1 = MCG_C1_CLKS(0) | MCG_C1_FRDIV(4);
@@ -438,7 +449,11 @@ void ResetHandler(void)
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST(3)) ;
// now we're in PEE mode
// 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
#endif
// 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);


+ 4
- 1
teensy3/mk20dx128.h Прегледај датотеку

@@ -38,7 +38,10 @@
//#define F_BUS 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_MEM 24000000
#elif (F_CPU == 48000000)

+ 4
- 2
teensy3/pins_teensy.c Прегледај датотеку

@@ -323,7 +323,7 @@ extern void usb_init(void);
#if F_BUS == 48000000
#define DEFAULT_FTM_MOD (49152 - 1)
#define DEFAULT_FTM_PRESCALE 1
#else
#elif F_BUS == 24000000
#define DEFAULT_FTM_MOD (49152 - 1)
#define DEFAULT_FTM_PRESCALE 0
#endif
@@ -685,7 +685,9 @@ void delay(uint32_t ms)
}
}

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

+ 3
- 1
teensy3/usb_seremu.c Прегледај датотеку

@@ -138,7 +138,9 @@ void usb_seremu_flush_input(void)
// software. If it's too long, we stall the user's program when no software is running.
#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)
#elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)

+ 3
- 1
teensy3/usb_serial.c Прегледај датотеку

@@ -147,7 +147,9 @@ void usb_serial_flush_input(void)
// software. If it's too long, we stall the user's program when no software is running.
#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)
#elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)

Loading…
Откажи
Сачувај