// // Main - It performs initialization, then runs a command processing loop to // read commands from the console. // int main(void) { int nStatus; FRESULT fresult; // // Set the clocking to run from the PLL at 50MHz // SysCtlClockSet(SYSCTL_OSCSRC_OSC2 | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(10) | SYSCTL_SYSDIV(2)); SysCtlAuxClockSet(SYSCTL_OSCSRC_OSC2 | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(12) | SYSCTL_SYSDIV(2)); //60 MHz #ifdef _FLASH // // Copy time critical code and Flash setup code to RAM // This includes the following functions: InitFlash_Bank0(); // The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart // symbols are created by the linker. Refer to the device .cmd file. // memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); // // Call Flash Initialization to setup flash waitstates // This function must reside in RAM // InitFlash_Bank0(); #endif // // Initialize interrupt controller and vector table // InitPieCtrl(); InitPieVectTable(); // // Set the system tick to fire 100 times per second. // SysTickInit(); SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / 100); SysTickIntRegister(SysTickHandler); SysTickIntEnable(); SysTickEnable(); // // Enable Interrupts // IntMasterEnable(); // // Configure UART0 for debug output. // ConfigureUART(); // // Print hello message to user. // UARTprintf("\n\nSD Card Example Program\n"); UARTprintf("Type \'help\' for help.\n"); // // Mount the file system, using logical disk 0. // fresult = f_mount(0, &g_sFatFs); if(fresult != FR_OK) { UARTprintf("f_mount error: %s\n", StringFromFresult(fresult)); return(1); } // // Enter an (almost) infinite loop for reading and processing commands from // the user. // while(1) { // // Print a prompt to the console. Show the CWD. // UARTprintf("\n%s> ", g_cCwdBuf); // // Get a line of text from the user. // UARTgets(g_cCmdBuf, sizeof(g_cCmdBuf)); // // Pass the line from the user to the command processor. // It will be parsed and valid commands executed. // nStatus = CmdLineProcess(g_cCmdBuf); // // Handle the case of bad command. // if(nStatus == CMDLINE_BAD_CMD) { UARTprintf("Bad command!\n"); } // // Handle the case of too many arguments. // else if(nStatus == CMDLINE_TOO_MANY_ARGS) { UARTprintf("Too many arguments for command processor!\n"); } // // Otherwise the command was executed. Print the error // code if one was returned. // else if(nStatus != 0) { UARTprintf("Command returned error code %s\n", StringFromFresult((FRESULT)nStatus)); } } }
void InitSysCtrl(void) { // Disable the watchdog DisableDog(); #ifdef _FLASH // Copy time critical code and Flash setup code to RAM // This includes the following functions: InitFlash(); // The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart // symbols are created by the linker. Refer to the device .cmd file. memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); // Call Flash Initialization to setup flash waitstates // This function must reside in RAM InitFlash_Bank0(); #endif // *IMPORTANT* // The Device_cal function, which copies the ADC & oscillator calibration values // from TI reserved OTP into the appropriate trim registers, occurs automatically // in the Boot ROM. If the boot ROM code is bypassed during the debug process, the // following function MUST be called for the ADC and oscillators to function according // to specification. The clocks to the ADC MUST be enabled before calling this // function. // See the device data manual and/or the ADC Reference // Manual for more information. EALLOW; //enable pull-ups on unbonded IOs as soon as possible to reduce power consumption. GPIO_EnableUnbondedIOPullups(); CpuSysRegs.PCLKCR13.bit.ADC_A = 1; CpuSysRegs.PCLKCR13.bit.ADC_B = 1; CpuSysRegs.PCLKCR13.bit.ADC_C = 1; CpuSysRegs.PCLKCR13.bit.ADC_D = 1; //check if device is trimmed if(*((Uint16 *)0x5D1B6) == 0x0000){ //device is not trimmed, apply static calibration values AnalogSubsysRegs.ANAREFTRIMA.all = 31709; AnalogSubsysRegs.ANAREFTRIMB.all = 31709; AnalogSubsysRegs.ANAREFTRIMC.all = 31709; AnalogSubsysRegs.ANAREFTRIMD.all = 31709; } CpuSysRegs.PCLKCR13.bit.ADC_A = 0; CpuSysRegs.PCLKCR13.bit.ADC_B = 0; CpuSysRegs.PCLKCR13.bit.ADC_C = 0; CpuSysRegs.PCLKCR13.bit.ADC_D = 0; EDIS; // Initialize the PLL control: PLLCR and CLKINDIV // F28_PLLCR and F28_CLKINDIV are defined in F2837xS_Examples.h // Note: The internal oscillator CANNOT be used as the PLL source if the // PLLSYSCLK is configured to frequencies above 194 MHz. InitSysPll(XTAL_OSC,IMULT_20,FMULT_0,PLLCLK_BY_2); //PLLSYSCLK = 10Mhz(OSCCLK) * 40 (IMULT) * 1 (FMULT) / 2 (PLLCLK_BY_2) //Turn on all peripherals InitPeripheralClocks(); }