Part Number: MSP432P401R Tool/software: Code Composer Studio I have an MSP432P401R Rev D (as per the chip itself) using a XDS110-ET Debugger. I have been using this board without issue for the semester for a microcontroller class and it worked great. One of my instructors for a signals course uses the board for a lab involving DAC with small program he came up with. (included below). I had it working on a school computer using code composer 6 however when I bring it home I am no longer able to run it nor any other program on my board (using code composer 9). I have ran the factory reset script multiple times to no avail. I'm at a bit of a loss here as to what to do. #include "msp.h" // Pin Assignments // P5.5 ADC input // P2.4 PWM output // P1.5 Digital output for indicating computation time /* DriverLib Includes */ #include /* Standard Includes */ #include #include #define PWM_PERIOD 480 // 48MHz SMCLK Clock / ?? ticks = 100 kHz PWM frequency #define ADC_DIVIDER 10 // Divider of 10 gives sampling freq of 100 kHz / 10 = 10 kHz // global variables for passing information between interrupt service routines and other functions volatile uint16_t intervalFlag=0; // flag set when sampling interval complete and sample is ready volatile int adcResult=0; volatile unsigned int adcCount=1; void digitalFilter(void); Timer_A_PWMConfig pwmConfig = { TIMER_A_CLOCKSOURCE_SMCLK, TIMER_A_CLOCKSOURCE_DIVIDER_1, PWM_PERIOD, TIMER_A_CAPTURECOMPARE_REGISTER_1, TIMER_A_OUTPUTMODE_RESET_SET, (int) (PWM_PERIOD/2) }; void main(void) { /* Halting the watchdog */ MAP_WDT_A_holdTimer(); /* Enable FPU Module(); */ MAP_FPU_enableModule(); /* Setting MCLK to DCO at 48 MHz * Setting SMCLK to 48 MHz */ MAP_CS_setDCOFrequency(48000000); MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); MAP_PCM_setPowerState(PCM_AM_LF_VCORE0); /* Configuring GPIO2.4 as peripheral output for PWM */ MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION); /* Configuring Timer_A0 to to have corresponding period/duty cycle*/ MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig); /* Initializing ADC (MCLK/1/1) */ MAP_ADC14_enableModule(); MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0); /* Configuring ADC Memory (ADC_MEM0 A0/A1) in repeat mode * with use of external references */ MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true); MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A0, false); /* Configuring GPIOs (5.5 A0) */ MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5, GPIO_TERTIARY_MODULE_FUNCTION); /* Configuring P1.5 as output for computation time measurement*/ MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN5); /* Configuring the sample trigger to be sourced from Timer_A0 and setting it * to automatic iteration after it is triggered*/ MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false); /* Enabling the interrupt when a conversion on channel 1 is complete and * enabling conversions */ MAP_ADC14_enableInterrupt(ADC_INT0); MAP_ADC14_enableConversion(); /* Enabling Interrupts */ MAP_Interrupt_enableInterrupt(INT_ADC14); MAP_Interrupt_enableMaster(); /* Wait for interrupts */ intervalFlag=0; while(1) { if(intervalFlag) { MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5); digitalFilter(); MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5); intervalFlag=0; } } } // function to read reference input, determine error term, filter and generate PWM output void digitalFilter(void) { volatile static float K=1.0,T_S = 0.0001111, x_n, y_n, x_n_1, y_n_1, dutyCycle; // variables for calculation // The ADC value is between 0 and 16384 (14-bit) corresponding to a range from 0 to 3.3 V x_n = (float) (3.3) * (adcResult) / 16384.0; // Set output according to digital filter y_n = K*y_n_1*(T_S/2)*(x_n+x_n_1); // Set duty cycle for PWM such that the average is equal to the intended output (PWM peak high level is 3.3 V) dutyCycle = y_n/3.3; x_n_1 = x_n; y_n_1= y_n; // update PWM output pwmConfig.dutyCycle = (int) (dutyCycle * PWM_PERIOD); // Limit PWM duty cycle range (min to max) if (pwmConfig.dutyCycle PWM_PERIOD) pwmConfig.dutyCycle = PWM_PERIOD; TIMER_A_CMSIS(TIMER_A0_BASE)->CCR[(pwmConfig.compareRegister>>1) - 1] = pwmConfig.dutyCycle; } /* ADC IRQ Handler */ void ADC14_IRQHandler(void) { static uint64_t status; status = MAP_ADC14_getEnabledInterruptStatus(); MAP_ADC14_clearInterruptFlag(status); if (status & ADC_INT0 & ~intervalFlag) { adcCount++; if(adcCount>ADC_DIVIDER) { adcResult = MAP_ADC14_getResult(ADC_MEM0); adcCount=1; intervalFlag=1; } } }
↧