本帖最后由 火山LF 于 2016-8-24 08:25 编辑
恭喜你,跟我情况一样,刚看到这帖子的时候,我还以为是我发的那个呢
可能的原因:
1、 没有配置低速时钟造成休眠后无法唤醒的情况
2、 单步调试遇到进入低功耗状态,还有延时循环等等,不要和编译器耗着,该跳过跳过,或者注释掉
3、 调试的时候你可以把进入低功耗状态注释掉,或者用几个NOP指令代替
下面是我修改的例程,你要是不行的话,用用我的(MSP430RF5969)我的板子是这块
#include "driverlib.h"
uint16_t Value_AD = 0;
uint16_t ADC_Get_Value = 0; // ADC采到的原始数据
uint16_t ADV_Get_Aver_Value = 0; //用于计算采ADC100次的平均值
void main(void)
{
// Stop WDT
WDT_A_hold(WDT_A_BASE);
//Set P1.0 as an output pin.
/*
* Select Port 1
* Set Pin 0 as output
*/
GPIO_setAsOutputPin(
GPIO_PORT_P1,
GPIO_PIN0
);
//Set P1.0 as Output Low.
/*
* Select Port 1
* Set Pin 0 to output Low.
*/
GPIO_setOutputLowOnPin(
GPIO_PORT_P1,
GPIO_PIN0
);
//Set P1.1 as Ternary Module Function Output.
/*
* Select Port 1
* Set Pin 1 to output Ternary Module Function, (A1, C1, VREF+, VeREF+).
*/
GPIO_setAsPeripheralModuleFunctionOutputPin(
GPIO_PORT_P3,
GPIO_PIN0,
GPIO_TERNARY_MODULE_FUNCTION
);
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
//Initialize the ADC12B Module
/*
* Base address of ADC12B Module
* Use internal ADC12B bit as sample/hold signal to start conversion
* USE MODOSC 5MHZ Digital Oscillator as clock source
* Use default clock divider/pre-divider of 1
* Not use internal channel
*/
ADC12_B_initParam initParam = {0};
initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC;
initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC;
initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_1;
initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1;
initParam.internalChannelMap = ADC12_B_NOINTCH;
ADC12_B_init(ADC12_B_BASE, &initParam);
//Enable the ADC12B module
ADC12_B_enable(ADC12_B_BASE);
/*
* Base address of ADC12B Module
* For memory buffers 0-7 sample/hold for 64 clock cycles
* For memory buffers 8-15 sample/hold for 4 clock cycles (default)
* Disable Multiple Sampling
*/
ADC12_B_setupSamplingTimer(ADC12_B_BASE,
ADC12_B_CYCLEHOLD_64_CYCLES,
ADC12_B_CYCLEHOLD_64_CYCLES,
ADC12_B_MULTIPLESAMPLESDISABLE);
//Configure Memory Buffer
/*
* Base address of the ADC12B Module
* Configure memory buffer 0
* Map input A1 to memory buffer 0
* Vref+ = AVcc
* Vref- = AVss
* Memory buffer 0 is not the end of a sequence
*/
ADC12_B_configureMemoryParam configureMemoryParam = {0};
configureMemoryParam.memoryBufferControlIndex = ADC12_B_MEMORY_0;
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A12;
configureMemoryParam.refVoltageSourceSelect =
ADC12_B_VREFPOS_AVCC_VREFNEG_VSS;
configureMemoryParam.endOfSequence = ADC12_B_NOTENDOFSEQUENCE;
configureMemoryParam.windowComparatorSelect =
ADC12_B_WINDOW_COMPARATOR_DISABLE;
configureMemoryParam.differentialModeSelect =
ADC12_B_DIFFERENTIAL_MODE_DISABLE;
ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam);
ADC12_B_clearInterrupt(ADC12_B_BASE,
0,
ADC12_B_IFG0
);
//Enable memory buffer 0 interrupt
ADC12_B_enableInterrupt(ADC12_B_BASE,
ADC12_B_IE0,
0,
0);
while(1)
{
__delay_cycles(5000);
//Enable/Start sampling and conversion
/*
* Base address of ADC12B Module
* Start the conversion into memory buffer 0
* Use the single-channel, single-conversion mode
*/
ADC12_B_startConversion(ADC12_B_BASE,
ADC12_B_MEMORY_0,
ADC12_B_SINGLECHANNEL);
__no_operation(); // For debugger
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(ADC12_VECTOR)))
#endif
void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,12))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC12BMEMx Overflow
case 4: break; // Vector 4: Conversion time overflow
case 6: break; // Vector 6: ADC12BHI
case 8: break; // Vector 8: ADC12BLO
case 10: break; // Vector 10: ADC12BIN
case 12: // Vector 12: ADC12BMEM0 Interrupt
Value_AD = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);
ADC_Get_Value = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);
if (ADV_Get_Aver_Value == 0) {
ADV_Get_Aver_Value = ADC_Get_Value;
}
ADC_Get_Value = (ADV_Get_Aver_Value + ADC_Get_Value) / 2;
ADV_Get_Aver_Value = ADC_Get_Value;
if(ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0) >= 0x7ff)
{
//Set P1.0 LED on
/*
* Select Port 1
* Set Pin 0 to output high.
*/
GPIO_setOutputHighOnPin(
GPIO_PORT_P1,
GPIO_PIN0
);
}
else
{
//Set P1.0 LED off
/*
* Select Port 1
* Set Pin 0 to output high.
*/
GPIO_setOutputLowOnPin(
GPIO_PORT_P1,
GPIO_PIN0
);
}
后面我发现其实有低功耗的模式也是可以的,你也可以尝试把你的CCS关闭,重新打开再试一试,之前不可以,过了一天发现又可以了
你所选择的通道外接了电压没有?
|