This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P401R
Tool/software: Code Composer Studio
/* DriverLib Includes */ #include <ti/devices/msp432p4xx/driverlib/driverlib.h> /* Application Defines */ #define TIMER_PERIOD 0x2DC6 uint16_t buffer[66]={0}; /* Timer_A UpMode Configuration Parameter */ const Timer_A_UpModeConfig upModeConfig = { TIMER_A_CLOCKSOURCE_SMCLK, // ACLK Clock Source TIMER_A_CLOCKSOURCE_DIVIDER_10, // ACLK/1 = 32Khz 1, TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer ISR TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0 TIMER_A_DO_CLEAR // Clear Counter }; /* Timer_A Compare Configuration Parameter const Timer_A_CompareModeConfig compareConfig = { TIMER_A_CAPTURECOMPARE_REGISTER_1, // Use CCR1 TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt TIMER_A_OUTPUTMODE_SET_RESET, // Toggle output but 1 // 16000 Period };*/ int main(void) { /* Stop WDT */ WDT_A_holdTimer(); /* Configuring P1.0 as output */ GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); /* Configuring Timer_A1 for Up Mode */ Timer_A_configureUpMode(TIMER_A1_BASE, &upModeConfig); /* Enabling interrupts and starting the timer */ Interrupt_enableSleepOnIsrExit(); REF_A_setReferenceVoltage(REF_A_VREF2_5V); REF_A_enableReferenceVoltage(); ADC14_disableConversion(); ADC14_enableModule(); ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0); GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN7|GPIO_PIN6 |GPIO_PIN4, GPIO_TERTIARY_MODULE_FUNCTION); GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P9, GPIO_PIN0 | GPIO_PIN1, GPIO_TERTIARY_MODULE_FUNCTION); ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM2, false); ADC14_configureConversionMemory(ADC_MEM0,ADC_VREFPOS_AVCC_VREFNEG_VSS , ADC_INPUT_A0, false); ADC14_configureConversionMemory(ADC_MEM1,ADC_VREFPOS_AVCC_VREFNEG_VSS , ADC_INPUT_A16, false); ADC14_configureConversionMemory(ADC_MEM2,ADC_VREFPOS_AVCC_VREFNEG_VSS , ADC_INPUT_A17, false); //ADC14_enableInterrupt(ADC_INT2); /* Enabling Interrupts Interrupt_enableInterrupt(INT_ADC14);*/ ADC14_enableConversion(); ADC14_toggleConversionTrigger(); ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false); ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION); Interrupt_enableInterrupt(INT_TA1_0); /* Enabling MASTER interrupts */ Interrupt_enableMaster(); Timer_A_startCounter(TIMER_A1_BASE, TIMER_A_UP_MODE); /* Sleeping when not in use */ while (1) { PCM_gotoLPM0(); } } void TA1_0_IRQHandler(void) { uint16_t index=0; GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); ADC14_disableConversion(); // ADC14_getMultiSequenceResult(resultsBuffer); buffer[index] = ADC14->MEM[0]; buffer[index+1] = ADC14->MEM[1]; buffer[index+2] = ADC14->MEM[2]; index=index+3; if(index==66) { index=0; } Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0); ADC14_enableConversion(); //ADC14_toggleConversionTrigger(); }
when i debug this code ,it stuck at cpu.wfi().what is wrong? is there any solution?
i changed as you suggested, but still stuck at cpu.wfi().it seem it does not matter
What does the code look like now? There many pieces to get right, and I just outlined the changes.
How do you know that the code is stuck in WFI? Do you (ever) reach a breakpoint set in TA1_1_IRQHandler?
When the code is operating correctly (it wasn't before), it is still spending most of its time waiting in wfi(); if you pause the debugger, you will probably find it there.
[Edit: Fixed ISR name]
I would recommend starting with just the timer and then adding the ADC. You have used Interrupt_enableSleepOnIsrExit(); , so the device will be in sleep mode most of the time, ie wifi. Also, you use the upModeConfiguration with the interrupt disabled. You need to enable the peripheral, NVIC, and the master enable.
Chris
**Attention** This is a public forum