jiyu7551 发表于 2024-3-19 15:02

MSP430FR5594 用库函数实现定时器触发AD问题请教

<p>我用的芯片是MSP430FR5994,使用的是库函数<br />
我AD用软件触发没有问题,能进入中断<br />
但是我用定时器触发就不行了<br />
定时器单独跑也没有问题,PWM信号 IO脚也出来了<br />
但是AD 用定时器触发就是不行</p>

<p>//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************<br />
int main(void)<br />
{<br />
&nbsp;&nbsp; &nbsp;WDTCTL = WDTPW | WDTHOLD;&nbsp;&nbsp; &nbsp;// stop watchdog timer<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;PMM_unlockLPM5();<br />
&nbsp;&nbsp; &nbsp;CS_init();<br />
&nbsp;&nbsp; &nbsp;IO_Init();<br />
&nbsp;&nbsp; &nbsp;Timer_Init();<br />
&nbsp; &nbsp; Ad_init();</p>

<p>&nbsp;&nbsp; &nbsp;while(1)<br />
&nbsp;&nbsp; &nbsp;{</p>

<p>//&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_startConversion(ADC12_B_BASE, ADC12_B_MEMORY_0, ADC12_B_SINGLECHANNEL);</p>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//LPM0, ADC12_A_ISR will force exit<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__bis_SR_register(LPM0_bits + GIE);<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//for Debugger<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__no_operation();</p>

<p><br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;GPIO_setOutputLowOnPin(GPIO_PORT_P2,GPIO_PIN0);</p>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;GPIO_setOutputHighOnPin(GPIO_PORT_P2,GPIO_PIN0);<br />
&nbsp;&nbsp; &nbsp;}</p>

<p>&nbsp;&nbsp; &nbsp;return 0;</p>

<p>}</p>

<p>//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************<br />
void CS_init()<br />
{<br />
&nbsp; &nbsp; // Set PJ.4 and PJ.5 as Secondary Module Function Input, LFXT.<br />
&nbsp; &nbsp; &nbsp;/* Initializes Clock System DCO = 8MHz */</p>

<p><br />
&nbsp; &nbsp; CS_setDCOFreq(CS_DCORSEL_0, CS_DCOFSEL_3);<br />
&nbsp; &nbsp; CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);<br />
&nbsp; &nbsp; CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2 );<br />
&nbsp; &nbsp; CS_initClockSignal(CS_ACLK, CS_VLOCLK_SELECT, CS_CLOCK_DIVIDER_1);</p>

<p>}</p>

<p>//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************</p>

<p>void Ad_init(void)<br />
{<br />
&nbsp; &nbsp; ADC12_B_initParam param1 = {0};<br />
&nbsp; &nbsp; ADC12_B_configureMemoryParam param = {0};</p>

<p>&nbsp; &nbsp; GPIO_setAsPeripheralModuleFunctionOutputPin(<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_PORT_P3,<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_TERNARY_MODULE_FUNCTION<br />
&nbsp; &nbsp; );</p>

<p><br />
&nbsp;// &nbsp; param1.sampleHoldSignalSourceSelect=ADC12_B_SAMPLEHOLDSOURCE_SC;<br />
&nbsp; &nbsp; param1.sampleHoldSignalSourceSelect=ADC12_B_SAMPLEHOLDSOURCE_1;<br />
&nbsp; &nbsp; param1.clockSourceSelect=ADC12_B_CLOCKSOURCE_MCLK;<br />
&nbsp; &nbsp; param1.clockSourceDivider=ADC12_B_CLOCKDIVIDER_1;<br />
&nbsp; &nbsp; param1.clockSourcePredivider=ADC12_B_CLOCKPREDIVIDER__1;<br />
&nbsp; &nbsp; param1.internalChannelMap=ADC12_B_NOINTCH;</p>

<p>&nbsp; &nbsp; ADC12_B_init(ADC12_B_BASE,&amp;param1);</p>

<p>&nbsp; &nbsp; ADC12_B_setupSamplingTimer(ADC12_B_BASE,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_CYCLEHOLD_64_CYCLES,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_CYCLEHOLD_4_CYCLES,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_MULTIPLESAMPLESENABLE);</p>

<p><br />
&nbsp; &nbsp; param.memoryBufferControlIndex = ADC12_B_MEMORY_0;<br />
&nbsp; &nbsp; param.inputSourceSelect = ADC12_B_INPUT_A12;<br />
&nbsp; &nbsp; param.refVoltageSourceSelect = ADC12_B_VREFPOS_AVCC_VREFNEG_VSS;<br />
&nbsp; &nbsp; param.endOfSequence = ADC12_B_NOTENDOFSEQUENCE;<br />
&nbsp; &nbsp; param.windowComparatorSelect = ADC12_B_WINDOW_COMPARATOR_DISABLE;<br />
&nbsp; &nbsp; param.differentialModeSelect = ADC12_B_DIFFERENTIAL_MODE_DISABLE;<br />
&nbsp; &nbsp; ADC12_B_configureMemory(ADC12_B_BASE ,&amp;param);</p>

<p><br />
&nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_clearInterrupt(ADC12_B_BASE,ADC12IFG0,0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12_B_enableInterrupt(ADC12_B_BASE, ADC12IE0,0,0);</p>

<p>&nbsp; &nbsp;ADC12_B_enable(ADC12_B_BASE);</p>

<p>}</p>

<p>//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************<br />
void Timer_Init(void)<br />
{<br />
/*<br />
&nbsp; &nbsp; Timer_A_initUpModeParam htim = {0};<br />
&nbsp; &nbsp; htim.clockSource = TIMER_A_CLOCKSOURCE_SMCLK; &nbsp; //<br />
// &nbsp; &nbsp;htim.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_2; &nbsp; &nbsp;//<br />
&nbsp; &nbsp; htim.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_32; &nbsp; &nbsp;//<br />
&nbsp; &nbsp; htim.timerPeriod = TIMER_PERIOD - 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />
&nbsp; &nbsp; htim.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_ENABLE; //<br />
&nbsp;// &nbsp; htim.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE; //<br />
&nbsp; &nbsp; htim.captureCompareInterruptEnable_CCR0_CCIE = TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE;<br />
&nbsp;// &nbsp; htim.timerClear = TIMER_A_DO_CLEAR; //<br />
&nbsp; &nbsp; htim.timerClear = TIMER_A_SKIP_CLEAR; //<br />
&nbsp; &nbsp; htim.startTimer = false; //</p>

<p><br />
&nbsp; &nbsp; Timer_A_initUpMode(TIMER_A0_BASE, &amp;htim);<br />
*/<br />
&nbsp; /*<br />
&nbsp; &nbsp; Timer_A_initContinuousModeParam initContParam = {0};</p>

<p>&nbsp; &nbsp; Timer_A_initUpModeParam Param={0};</p>

<p>&nbsp; &nbsp; initContParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;<br />
&nbsp; &nbsp; initContParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;<br />
&nbsp; &nbsp; initContParam.timerInterruptEnable_TAIE=TIMER_A_TAIE_INTERRUPT_ENABLE;<br />
&nbsp; &nbsp; initContParam.timerClear=TIMER_A_DO_CLEAR;<br />
&nbsp; &nbsp; initContParam.startTimer = true;</p>

<p>&nbsp; &nbsp; Timer_A_initContinuousMode(TIMER_A1_BASE, &amp;initContParam);<br />
*/</p>

<p><br />
/*<br />
&nbsp; &nbsp; //Start timer in continuous mode sourced by SMCLK<br />
&nbsp; &nbsp; Timer_A_initContinuousModeParam initContParam = {0};<br />
&nbsp; &nbsp; initContParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;<br />
&nbsp; &nbsp; initContParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;<br />
&nbsp; &nbsp; initContParam.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE;<br />
&nbsp; &nbsp; initContParam.timerClear = TIMER_A_DO_CLEAR;<br />
&nbsp; &nbsp; initContParam.startTimer = false;<br />
&nbsp; &nbsp; Timer_A_initContinuousMode(TIMER_A1_BASE, &amp;initContParam);</p>

<p>&nbsp; &nbsp; //Initiaze compare mode<br />
&nbsp; &nbsp; Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE,<br />
&nbsp; &nbsp; &nbsp; &nbsp; TIMER_A_CAPTURECOMPARE_REGISTER_0<br />
&nbsp; &nbsp; &nbsp; &nbsp; );<br />
*/<br />
/*<br />
&nbsp; &nbsp; Timer_A_initCompareModeParam initCompParam = {0};<br />
&nbsp; &nbsp; initCompParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;<br />
&nbsp; &nbsp; initCompParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE;<br />
&nbsp;// &nbsp; initCompParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE;<br />
&nbsp; &nbsp; initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_TOGGLE;<br />
// &nbsp; &nbsp;initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_SET_RESET;<br />
&nbsp; &nbsp; initCompParam.compareValue = 10;<br />
&nbsp; &nbsp; Timer_A_initCompareMode(TIMER_A0_BASE, &amp;initCompParam);<br />
*/</p>

<p>&nbsp; &nbsp; Timer_A_outputPWMParam htim1 = {0};</p>

<p>&nbsp; &nbsp; htim1.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;</p>

<p>&nbsp; &nbsp; htim1.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_32;</p>

<p>&nbsp; &nbsp; htim1.timerPeriod = TIMER_PERIOD - 1;</p>

<p>&nbsp; &nbsp; htim1.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;</p>

<p>&nbsp; &nbsp; htim1.compareOutputMode = TIMER_A_OUTPUTMODE_RESET_SET;</p>

<p>&nbsp; &nbsp; htim1.dutyCycle = TIMER_PERIOD / 2 ;</p>

<p>&nbsp; &nbsp; Timer_A_outputPWM(TIMER_A0_BASE, &amp;htim1);</p>

<p><br />
&nbsp;// &nbsp; Timer_A_startCounter( TIMER_A0_BASE, TIMER_A_UP_MODE );</p>

<p><br />
}</p>

<p>//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************<br />
void IO_Init(void)<br />
{</p>

<p><br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setAsOutputPin(GPIO_PORT_P3,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setAsOutputPin(GPIO_PORT_P4,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);</p>

<p>&nbsp; // &nbsp; &nbsp; &nbsp;GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setOutputHighOnPin(GPIO_PORT_P2,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setOutputHighOnPin(GPIO_PORT_P4,GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3+GPIO_PIN4+GPIO_PIN5+GPIO_PIN6+GPIO_PIN7);</p>

<p><br />
&nbsp; // &nbsp; &nbsp; &nbsp;GPIO_setAsInputPin(GPIO_PORT_P1,GPIO_PIN0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1,GPIO_PIN0,GPIO_PRIMARY_MODULE_FUNCTION);</p>

<p>}<br />
&nbsp;</p>

jiyu7551 发表于 2024-3-19 15:06

<p><br />
//*****************************************************************************<br />
// * main.c<br />
// ******************************************************************************<br />
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)<br />
#pragma vector=ADC12_VECTOR<br />
__interrupt<br />
#elif defined(__GNUC__)<br />
__attribute__((interrupt(ADC12_VECTOR)))<br />
#endif<br />
void ADC12_ISR(void)<br />
{<br />
&nbsp; switch(__even_in_range(ADC12IV,12))<br />
&nbsp; {<br />
&nbsp; &nbsp; case &nbsp;0: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector &nbsp;0: &nbsp;No interrupt<br />
&nbsp; &nbsp; case &nbsp;2: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector &nbsp;2: &nbsp;ADC12BMEMx Overflow<br />
&nbsp; &nbsp; case &nbsp;4: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector &nbsp;4: &nbsp;Conversion time overflow<br />
&nbsp; &nbsp; case &nbsp;6: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector &nbsp;6: &nbsp;ADC12BHI<br />
&nbsp; &nbsp; case &nbsp;8: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector &nbsp;8: &nbsp;ADC12BLO<br />
&nbsp; &nbsp; case 10: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 10: &nbsp;ADC12BIN<br />
&nbsp; &nbsp; case 12:<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Vector 12: &nbsp;ADC12BMEM0 Interrupt<br />
&nbsp; &nbsp; &nbsp; &nbsp; g_usAdcData= &nbsp; ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; __bic_SR_register_on_exit(LPM0_bits); // Exit active CPU<br />
&nbsp; &nbsp; &nbsp; break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Clear CPUOFF bit from 0(SR)<br />
&nbsp; &nbsp; case 14: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 14: &nbsp;ADC12BMEM1<br />
&nbsp; &nbsp; case 16: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 16: &nbsp;ADC12BMEM2<br />
&nbsp; &nbsp; case 18: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 18: &nbsp;ADC12BMEM3<br />
&nbsp; &nbsp; case 20: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 20: &nbsp;ADC12BMEM4<br />
&nbsp; &nbsp; case 22: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 22: &nbsp;ADC12BMEM5<br />
&nbsp; &nbsp; case 24: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 24: &nbsp;ADC12BMEM6<br />
&nbsp; &nbsp; case 26: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 26: &nbsp;ADC12BMEM7<br />
&nbsp; &nbsp; case 28: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 28: &nbsp;ADC12BMEM8<br />
&nbsp; &nbsp; case 30: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 30: &nbsp;ADC12BMEM9<br />
&nbsp; &nbsp; case 32: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 32: &nbsp;ADC12BMEM10<br />
&nbsp; &nbsp; case 34: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 34: &nbsp;ADC12BMEM11<br />
&nbsp; &nbsp; case 36: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 36: &nbsp;ADC12BMEM12<br />
&nbsp; &nbsp; case 38: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 38: &nbsp;ADC12BMEM13<br />
&nbsp; &nbsp; case 40: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 40: &nbsp;ADC12BMEM14<br />
&nbsp; &nbsp; case 42: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 42: &nbsp;ADC12BMEM15<br />
&nbsp; &nbsp; case 44: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 44: &nbsp;ADC12BMEM16<br />
&nbsp; &nbsp; case 46: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 46: &nbsp;ADC12BMEM17<br />
&nbsp; &nbsp; case 48: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 48: &nbsp;ADC12BMEM18<br />
&nbsp; &nbsp; case 50: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 50: &nbsp;ADC12BMEM19<br />
&nbsp; &nbsp; case 52: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 52: &nbsp;ADC12BMEM20<br />
&nbsp; &nbsp; case 54: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 54: &nbsp;ADC12BMEM21<br />
&nbsp; &nbsp; case 56: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 56: &nbsp;ADC12BMEM22<br />
&nbsp; &nbsp; case 58: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 58: &nbsp;ADC12BMEM23<br />
&nbsp; &nbsp; case 60: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 60: &nbsp;ADC12BMEM24<br />
&nbsp; &nbsp; case 62: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 62: &nbsp;ADC12BMEM25<br />
&nbsp; &nbsp; case 64: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 64: &nbsp;ADC12BMEM26<br />
&nbsp; &nbsp; case 66: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 66: &nbsp;ADC12BMEM27<br />
&nbsp; &nbsp; case 68: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 68: &nbsp;ADC12BMEM28<br />
&nbsp; &nbsp; case 70: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 70: &nbsp;ADC12BMEM29<br />
&nbsp; &nbsp; case 72: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 72: &nbsp;ADC12BMEM30<br />
&nbsp; &nbsp; case 74: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 74: &nbsp;ADC12BMEM31<br />
&nbsp; &nbsp; case 76: break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Vector 76: &nbsp;ADC12BRDY<br />
&nbsp; &nbsp; default: break;<br />
&nbsp; }<br />
}</p>

<p>//******************************************************************************<br />
//<br />
//This is the TIMER1_A3 interrupt vector service routine.<br />
//<br />
//******************************************************************************</p>

<p>#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)<br />
#pragma vector=TIMER0_A1_VECTOR<br />
__interrupt<br />
#elif defined(__GNUC__)<br />
__attribute__((interrupt(TIMER0_A1_VECTOR)))<br />
#endif<br />
void TIMER0_A1_ISR (void)<br />
{<br />
&nbsp; &nbsp; switch(TA0IV)<br />
&nbsp; &nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_NONE:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_TACCR1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_toggleOutputOnPin(<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PORT_P2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_TACCR2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_6:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case TA0IV_TAIFG:</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Toggle P1.0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_toggleOutputOnPin(<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PORT_P2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />
&nbsp; &nbsp; &nbsp;}</p>

<p>}<br />
&nbsp;</p>

tagetage 发表于 2024-3-22 22:04

<p>这个应该是寄存器设置的问题,你应该看TI的事例代码。MSP430FR5994的代码如下。</p>

<p>https://www.ti.com.cn/tool/cn/download/SLAC710</p>

tagetage 发表于 2024-3-22 22:06

<p>下来后看readme.txt 里面有关于ADC方面的例程。</p>

<p>msp430fr599x_active_01.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Active mode test<br />
msp430fr599x_active_02.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Active Mode Test with 100% CHR<br />
msp430fr599x_adc12_01.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Sample A1, Avcc Ref, Set P1.0 if A1 &gt; 0.5*AVcc<br />
msp430fr599x_adc12_02.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Using the Internal Reference<br />
msp430fr599x_adc12_03.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Sample A2-A3 Differential,Set P1.0 if i/p&gt; 1V<br />
msp430fr599x_adc12_05.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Using an External Reference<br />
msp430fr599x_adc12_10.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Sample A10 Temp and Convert to oC and oF<br />
msp430fr599x_adc12_11.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Sample A1, T0A1 Trig, Ultra-Low Pwr<br />
msp430fr599x_adc12_21.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Window Comparator, 2.5V ref<br />
msp430fr599x_adc12_22.c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADC12, Window Comparator, 2.5V ref, 2&#39;s Complement</p>

jiyu7551 发表于 2024-3-24 15:45

tagetage 发表于 2024-3-22 22:04
这个应该是寄存器设置的问题,你应该看TI的事例代码。MSP430FR5994的代码如下。

https://www.ti.com.cn/ ...

<p>好的,我看一下,谢谢!</p>
页: [1]
查看完整版本: MSP430FR5594 用库函数实现定时器触发AD问题请教