Mark
I tried your OUT file, after loading I do not see anything, neither UART port output or USB device driver detection in the Windows.
Looks like to me even the Ext ref Oscillator did not turn ON and that maybe because PTA29 is NOT turned ON in your binary image.
I do this for enabling external clock:
void SystemConfigureClocks(uint32_t clkdiv1, bool enableUsb)
{
// CMSIS CLOCK_SETUP=1
/* SIM->SCGC5: PORTA=1 */
SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; /* Enable clock gate for ports to enable pin routing */
// /* This is for External CLOCK */
PORT_PCR_REG((PORTA_BASE_PTR), 29) = PORT_PCR_MUX(0x01); // set OSC_EN (PTA29) to be a GPIO function
GPIO_PDOR_REG(PTA_BASE_PTR) |= (uint32_t)0x20000000UL; // set to high
GPIO_PDDR_REG(PTA_BASE_PTR) |= (uint32_t)0x20000000UL; // make it an output
PORT_PCR_REG((PORTA_BASE_PTR), 19) = PORT_PCR_MUX(0x01) | PORT_PCR_DSE_MASK; // VSW_8V0_PWM
/* SIM->CLKDIV1: OUTDIV1=0,OUTDIV2=1,OUTDIV3=1,OUTDIV4=4,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
SIM->CLKDIV1 = clkdiv1; /* Update system prescalers */
/* SIM->SOPT2: PLLFLLSEL=1 */
BW_SIM_SOPT2_PLLFLLSEL(1); /* Select PLL as a clock source for various peripherals */
/* SIM->SOPT1: OSC32KSEL=3 */
SIM->SOPT1 = 0x00080000UL; /* LPO 1kHz oscillator drives 32 kHz clock for various peripherals */
/* PORTA->PCR[18]: ISF=0,MUX=0 */
PORTA->PCR[18] &= (uint32_t)~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
/* Switch to FBE Mode */
/* MCG->C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=0,LP=0,IRCS=0 */
MCG->C2 = 0x21U;
/* OSC->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
OSC->CR = 0x80U;
/* MCG->C7: OSCSEL=0 */
MCG->C7 &= (uint8_t)~(uint8_t)(MCG_C7_OSCSEL_MASK);
/* MCG->C1: CLKS=2,FRDIV=5,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
MCG->C1 = (MCG_C1_CLKS(0x02) | MCG_C1_FRDIV(0x05) | MCG_C1_IRCLKEN_MASK);
/* MCG->C4: DMX32=0,DRST_DRS=0 */
MCG->C4 = 0x00U;
/* MCG->C5: ??=0,PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=0x13 */
MCG->C5 = 0x33U;
/* MCG->C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0x18 */
MCG->C6 = 0x50U;
while((MCG->S & MCG_S_IREFST_MASK) != 0x00U) { /* Check that the source of the FLL reference clock is the external reference clock. */
}
while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
}
/* Switch to PBE Mode */
/* MCG->C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=0x18 */
MCG->C6 = 0x50U;
while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
}
while((MCG->S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait until locked */
}
/* Switch to PEE Mode */
/* MCG->C1: CLKS=0,FRDIV=5,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
MCG->C1 = 0x20U;
while((MCG->S & 0x0CU) != 0x0CU) { /* Wait until output of the PLL is selected */
}
// Set USB to 48MHz input clock if requested.
if (enableUsb)
{
/* Set USB input clock to 48MHz */
/* SIM->CLKDIV2: USBDIV=4,USBFRAC=1 */
SIM->CLKDIV2 = (uint32_t)((SIM->CLKDIV2 & (uint32_t)~(uint32_t)(
SIM_CLKDIV2_USBDIV(0x03)
)) | (uint32_t)(
SIM_CLKDIV2_USBDIV(0x04) |
SIM_CLKDIV2_USBFRAC_MASK
));
}
}