
Originally Posted by
defragster
Having the clocks going first makes sense - @mjs513 - can you post the complete few lines to put after setArmClock()? I keep seeing ref to a line I don't see in what was posted … don't see a pull request for the code
This is the entire function:
Code:
void ResetHandler(void)
{
unsigned int i;
#if defined(__IMXRT1062__)
IOMUXC_GPR_GPR17 = (uint32_t)&_flexram_bank_config;
IOMUXC_GPR_GPR16 = 0x00000007;
IOMUXC_GPR_GPR14 = 0x00AA0000;
__asm__ volatile("mov sp, %0" : : "r" ((uint32_t)&_estack) : );
#endif
// pin 13 - if startup crashes, use this to turn on the LED early for troubleshooting
//IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03 = 5;
//IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03 = IOMUXC_PAD_DSE(7);
//IOMUXC_GPR_GPR27 = 0xFFFFFFFF;
//GPIO7_GDIR |= (1<<3);
//GPIO7_DR_SET = (1<<3); // digitalWrite(13, HIGH);
// Initialize memory
memory_copy(&_stext, &_stextload, &_etext);
memory_copy(&_sdata, &_sdataload, &_edata);
memory_clear(&_sbss, &_ebss);
// enable FPU
SCB_CPACR = 0x00F00000;
// set up blank interrupt & exception vector table
for (i=0; i < NVIC_NUM_INTERRUPTS + 16; i++) _VectorsRam[i] = &unused_interrupt_vector;
for (i=0; i < NVIC_NUM_INTERRUPTS; i++) NVIC_SET_PRIORITY(i, 128);
SCB_VTOR = (uint32_t)_VectorsRam;
reset_PFD();
// Configure clocks
// TODO: make sure all affected peripherals are turned off!
// PIT & GPT timers to run from 24 MHz clock (independent of CPU speed)
CCM_CSCMR1 = (CCM_CSCMR1 & ~CCM_CSCMR1_PERCLK_PODF(0x3F)) | CCM_CSCMR1_PERCLK_CLK_SEL;
// UARTs run from 24 MHz clock (works if PLL3 off or bypassed)
CCM_CSCDR1 = (CCM_CSCDR1 & ~CCM_CSCDR1_UART_CLK_PODF(0x3F)) | CCM_CSCDR1_UART_CLK_SEL;
#if defined(__IMXRT1062__)
// Use fast GPIO6, GPIO7, GPIO8, GPIO9
IOMUXC_GPR_GPR26 = 0xFFFFFFFF;
IOMUXC_GPR_GPR27 = 0xFFFFFFFF;
IOMUXC_GPR_GPR28 = 0xFFFFFFFF;
IOMUXC_GPR_GPR29 = 0xFFFFFFFF;
#endif
// must enable PRINT_DEBUG_STUFF in debug/print.h
printf_debug_init();
printf("\n***********IMXRT Startup**********\n");
printf("test %d %d %d\n", 1, -1234567, 3);
configure_cache();
configure_systick();
usb_pll_start();
reset_PFD(); //TODO: is this really needed?
set_arm_clock(600000000);
//set_arm_clock(984000000); Ludicrous Speed
// Undo PIT timer usage by ROM startup
CCM_CCGR1 |= CCM_CCGR1_PIT(CCM_CCGR_ON);
PIT_MCR = 0;
PIT_TCTRL0 = 0;
PIT_TCTRL1 = 0;
PIT_TCTRL2 = 0;
PIT_TCTRL3 = 0;
// initialize RTC
if (!(SNVS_LPCR & SNVS_LPCR_SRTC_ENV)) {
// if SRTC isn't running, start it with default Jan 1, 2019
SNVS_LPSRTCLR = 1546300800u << 15;
SNVS_LPSRTCMR = 1546300800u >> 17;
SNVS_LPCR |= SNVS_LPCR_SRTC_ENV;
}
SNVS_HPCR |= SNVS_HPCR_RTC_EN | SNVS_HPCR_HP_TS;
while (millis() < 20) ; // wait at least 20ms before starting USB
usb_init();
analog_init();
pwm_init();
tempmon_init();
while (millis() < 300) ; // wait at least 300ms before calling user code
//printf("before C++ constructors\n");
__libc_init_array();
//printf("after C++ constructors\n");
//printf("before setup\n");
setup();
//printf("after setup\n");
while (1) {
//printf("loop\n");
loop();
yield();
}
}