Hi there,
I am trying to make the MSP432 ADC14 sample @ 1 Msps using the Driver Lib. The problem is that the MSP always ends up idling in the faultISR, when I use the function ADC14_getResultArray.
If I don't use this function, my code runs without crashing, but when I inspect the ADC memory registers, they are all zero.
Would be glad if someone could help! This is my code:
#include "msp.h"
#include "pcm.h"
#include "cs.h"
#include "adc14.h"
#include "flash.h"
#include "gpio.h"
#include "interrupt.h"
volatile uint32_t flag;
void adc14_ISR(void) {
ADC14_clearInterruptFlag(0xFFFFFFFF);
flag = TRUE;
}
void init_cs(void) {
// Configuring pins for peripheral/crystal usage and LED for output
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
GPIO_PIN3 | GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
// Configure SMCLK output at P7.0
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7, GPIO_PIN0,
GPIO_PRIMARY_MODULE_FUNCTION);
// Starting HFXT in non-bypass mode without a timeout. Before we start
// we have to change VCORE to 1 to support the 48MHz frequency
CS_setExternalClockSourceFrequency(32768, 27120000);
PCM_setCoreVoltageLevel(PCM_VCORE1);
FlashCtl_setWaitState(FLASH_BANK0, 2);
FlashCtl_setWaitState(FLASH_BANK1, 2);
CS_startHFXT(false);
// Configure clocks that we need
CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_16);
}
void init_adc(void) {
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN1,
GPIO_TERTIARY_MODULE_FUNCTION);
// Configure ADC
ADC14_enableModule();
ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0);
ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM31, true);
ADC14_setResolution(ADC_10BIT);
// Configuring ADC memories
uint32_t mem;
for(mem = ADC_MEM0; TRUE; mem <<= 1) {
ADC14_configureConversionMemory(mem, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A14, false);
if(mem == ADC_MEM31) break;
}
// Configuring timing
ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_64, ADC_PULSE_WIDTH_64);
// Enable interrupt for last ADC memory
ADC14_enableInterrupt(ADC_INT31);
ADC14_registerInterrupt(adc14_ISR);
}
void main(void) {
// Stop watchdog timer
WDTCTL = WDTPW | WDTHOLD;
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
P1DIR |= BIT0;
init_cs();
init_adc();
__enable_interrupt();
ADC14_enableConversion();
ADC14_toggleConversionTrigger();
flag = FALSE;
uint16_t res[32];
while(TRUE) {
if(flag) {
ADC14_getResultArray(ADC_MEM0, ADC_MEM31, res);
flag = FALSE;
}
}
}