Hello,
I am trying to debug my code but every time I launch the debuggging session in CCS it doesn't pause at the start of the main function but instead when I hit pause it shows that I am already in the FaultISR. I can see the global variables that I set before the main program but not any of the variables that I set inside the main function.
I have attached my code. Please help me figure out how to get the debugger to run until the start of the main function.
Regards,
Curtis
/* * GTBE_pllTest.c */ //Define Inputs\ #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_ssi.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" // Stellarisware #include "driverlib/sysctl.h" #include "driverlib/rom.h" #include "driverlib/debug.h" #include "driverlib/flash.h" // CMSIS #include <math.h> #include "arm_math.h" #include "math_helper.h" // PLL Loop Parameters #define PHASE_OFFSET 0.0 #define F_C 10000 // Center Frequency of the NCO // Test Input data //#define NUM_CYCLES 1000 #define F_S 100000 #define A 100000 #define F_IN 10100 #define K_GAIN -0.01 #define NUM_SAMPLES 2000 //FIR Filter Data #define NUM_TAPS 121 #define BLOCK_SIZE 1 #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /******************* * Flash Functions * *******************/ /** * Initializes the Flash * Protects the part of the flash memory from address codeStart through * codeStart + codeReserveLength by setting to only execute (FlashExecuteOnly) * Sets up the flash interrupt in case the program attempts to access the * protected flash portions. Make sure the ISR is added to the NVIC table * * \param codeStart - start location of flash memory that is to be reserved * it must land on a 2KB boundry * \param codeReserveLength - length of code to prtotect in flash memory * it must land on a 2KB boundry **/ void initFlash(uint32_t codeStart, uint32_t codeReserveLength) { int32_t status; uint32_t modCheck; uint32_t block; // Check codeStart and codeReserveLength to ensure the protected memory // block starts and ends on a 2KB boundry modCheck = codeStart - codeStart/0x800; modCheck = modCheck + codeReserveLength/0x800; ASSERT(modCheck == 0); // Setup code protection for(block = 0; block < (codeReserveLength/0x800); block++) { status = FlashProtectSet(0x800 * block, FlashExecuteOnly); ASSERT(status == 0) } //setup Flash Interrupt to handle any improper write attempts to flash FlashIntEnable(FLASH_INT_PROGRAM); } /** * Interrupt handler (ISR) that executes when an improper write to flash is attempted **/ void FLASH_badWriteISR(void) { while(1) { // Do nothing - save state for examination } } /****************** * FPU Functions * ******************/ /** * Initializes the FPU **/ void setupFPU(void) { // Lazy Stacking increases interrupt latency and stack usage // (only need if doing floating pt. in interrupts) //FPULazyStackingEnable(); ROM_FPUEnable(); } // Input float32_t g_sig_I[NUM_SAMPLES]; // PFD float32_t g_msig_I[1]; uint32_t gp_msig_I = 0x2800; // Address to save data to in flash float32_t g_msig_Q[1]; uint32_t gp_msig_Q = 0x3600; // Address to save data to in flash // FIR Filter uint32_t blockSize = BLOCK_SIZE; const float32_t firCoeffs32[NUM_TAPS] = { 0.0006830547454, 0.0007069055674, 0.0007422978673, 0.000790029838, 0.0008508535077, 0.0009254696142, 0.001014522694, 0.001118596418, 0.001238209203, 0.001373810118, 0.001525775132, 0.001694403697, 0.001879915716, 0.002082448903, 0.002302056559, 0.002538705765, 0.002792276037, 0.003062558419, 0.003349255047, 0.00365197918, 0.003970255708, 0.00430352213, 0.00465113001, 0.005012346894, 0.0053863587, 0.005772272552, 0.006169120058, 0.006575861016, 0.006991387523, 0.00741452848, 0.007844054463, 0.008278682938, 0.008717083793, 0.009157885164, 0.00959967952, 0.01004102998, 0.01048047682, 0.01091654416, 0.01134774676, 0.01177259695, 0.01218961154, 0.01259731883, 0.01299426559, 0.01337902392, 0.01375019813, 0.01410643139, 0.01444641227, 0.0147688811, 0.01507263604, 0.01535653896, 0.01561952094, 0.01586058754, 0.01607882362, 0.01627339785, 0.01644356679, 0.01658867855, 0.01670817598, 0.01680159946, 0.0168685891, 0.01690888657, 0.01692233637, 0.01690888657, 0.0168685891, 0.01680159946, 0.01670817598, 0.01658867855, 0.01644356679, 0.01627339785, 0.01607882362, 0.01586058754, 0.01561952094, 0.01535653896, 0.01507263604, 0.0147688811, 0.01444641227, 0.01410643139, 0.01375019813, 0.01337902392, 0.01299426559, 0.01259731883, 0.01218961154, 0.01177259695, 0.01134774676, 0.01091654416, 0.01048047682, 0.01004102998, 0.00959967952, 0.009157885164, 0.008717083793, 0.008278682938, 0.007844054463, 0.00741452848, 0.006991387523, 0.006575861016, 0.006169120058, 0.005772272552, 0.0053863587, 0.005012346894, 0.00465113001, 0.00430352213, 0.003970255708, 0.00365197918, 0.003349255047, 0.003062558419, 0.002792276037, 0.002538705765, 0.002302056559, 0.002082448903, 0.001879915716, 0.001694403697, 0.001525775132, 0.001373810118, 0.001238209203, 0.001118596418, 0.001014522694, 0.0009254696142, 0.0008508535077, 0.000790029838, 0.0007422978673, 0.0007069055674, 0.0006830547454 }; static float32_t firStateF32_I[BLOCK_SIZE + NUM_TAPS - 1]; //Declare State buffer of size (numTaps + blockSize - 1) static float32_t firStateF32_Q[BLOCK_SIZE + NUM_TAPS - 1]; static float32_t I_err[1]; //output of I FIR filter static float32_t Q_err[1]; //output of Q FIR filter // Loop Gain and phase offsets float32_t g_err[1]; uint32_t gp_err = 0x4400; // Address to save data to in flash float32_t g_errAdj; float32_t g_K = K_GAIN; float32_t g_phaseOffset = PHASE_OFFSET; // NCO float32_t g_currPhase[NUM_SAMPLES]; uint32_t gp_currPhase; float32_t g_nco_I[1]; float32_t g_nco_Q[1]; uint32_t gp_nco_I; uint32_t gp_nco_Q; /******** * Main * ********/ int main(void) { int i; // FIR Filter Variables arm_fir_instance_f32 S_I; arm_fir_instance_f32 S_Q; float32_t *inputF32_I, *outputF32_I; float32_t *inputF32_Q, *outputF32_Q; //Initialize input and output buffer pointers inputF32_I = &g_msig_I[0]; outputF32_I = &I_err[0]; inputF32_Q = &g_msig_Q[0]; outputF32_Q = &Q_err[0]; // NCO float32_t phaseInc; // // System Initialization // // Set system clock to 80 MHz (400MHz main PLL (divided by 5 - uses DIV400 bit) [16MHz external xtal drives PLL] ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); setupFPU(); initFlash(0x0, 0x2800); // Initialize FIR Filter /* Call FIR init function to initialize the instance structure. */ arm_fir_init_f32(&S_I, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32_I[0], blockSize); arm_fir_init_f32(&S_Q, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32_Q[0], blockSize); // // Generate Test Input cosine // for(i=0; i<NUM_SAMPLES; i++) { g_sig_I[i] = arm_cos_f32((2 * M_PI * F_IN / F_S) *i); } phaseInc = (2 * M_PI * F_C)/F_S; g_nco_I[0] = 1; g_nco_Q[0] = 0; FlashProgram(g_nco_I,gp_nco_I,4); gp_nco_I += 4; FlashProgram(g_nco_Q,gp_nco_Q,4); gp_nco_Q += 4; int n; // Main "Time" sim loop for(n = 0; n < NUM_SAMPLES; n++) { // // Phase Detection // // PD Multipliers g_msig_I[0] = g_sig_I[n] * g_nco_I[0]; g_msig_Q[0] = g_sig_I[n] * g_nco_Q[0]; FlashProgram(g_msig_I,gp_msig_I,4); gp_msig_I += 4; FlashProgram(g_msig_Q,gp_msig_Q,4); gp_msig_Q += 4; // PD FIR Filter arm_fir_f32(&S_I, inputF32_I, outputF32_I, blockSize); arm_fir_f32(&S_Q, inputF32_Q, outputF32_Q, blockSize); g_err[0] = atan2(Q_err[0],I_err[0]); // Take the 4 quadrant arctan FlashProgram(g_err,gp_err,4); gp_err += 4; g_errAdj = g_K * (g_err[0] + g_phaseOffset); if(n>0) g_currPhase[n] = g_currPhase[n] + phaseInc + g_errAdj; else g_currPhase[0] = 0; g_nco_I[0] = arm_cos_f32(g_currPhase[n]); g_nco_Q[0] = arm_sin_f32(g_currPhase[n]); FlashProgram(g_nco_I, gp_nco_I, 4); FlashProgram(g_nco_Q, gp_nco_Q, 4); } while(1) {} // End of program execution }