程序内容:RTC
、LCD
显示、ADC
电池采样;MSP430FR4133
可以做到7UA
,MSP430FR6972
却有40UA
;多余的电流经查ADC
(10UA
),AD
关闭,内部参考电压无法关闭而MSP430FR4133
可以关闭,为什么?void ADC12_Config() // MSP430FR6972{ PMMCTL0= SVSHE + PMMPW; while(REFCTL0& REFGENBUSY); // If refgenerator busy, WAIT REFCTL0 |= REFVSEL_1 + REFON; // Enable internal 2.0V reference //
参考电压配置 ADC12CTL0 &= ~ADC12ENC; // Disable ADC12 (
在ADC12ENC=0
的情况下,修改启动或关闭AD) ADC12CTL0 = ADC12SHT0_8 + ADC12ON; // Set sample time
采样保持时间 256ADCCLK
;启动AD ADC12CTL1 = ADC12SHP; // Enable sample timer ADCCLK = MODOSC; sampling timer
: 从采样保持器中获取信号 ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results
分辨率 ADC12CTL3 = ADC12BATMAP; // Enable internal 1/2 AVCC+ ADC12MCTL0 = ADC12VRSEL_1 + ADC12INCH_31; // ADC input ch A30 =>internal 1/2 AVCC+ ADC12IER0 |= ADC12IE0; // ADC_IFG upon convresult-ADCMEMO while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator //to settle ADC12CTL0 |= ADC12ENC; __delay_cycles(400);}ADC
中断 case ADC12IV_ADC12IFG0: // Vector 12: ADC12MEM0 Interrupt ui16Bat_Vol = (uint32_t)100*ADC12MEM0/0x3FF; if(ui16Bat_Vol_Old!=ui16Bat_Vol) { bADC_done_flag= true; ui16Bat_Vol_Old= ui16Bat_Vol; } //Exit from LPM0 and continue executing main while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT REFCTL0 = 0; while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator ADC12CTL0 &= ~ADC12ENC; ADC12CTL0 &= ~ADC12ON; //AD
关闭 break;
此帖出自
小平头技术问答
{
P4SEL0 |= BIT1 + BIT2; // Select pin4.1 pin4.2 as crystal function
do
{
CSCTL7 &= ~(XT1OFFG + DCOFFG); // Clear XT1 and DCO fault flag 清除 XT1 DCO 失效标志
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1 & OFIFG); // Test oscillator fault flag 如果失效标志存在
CSCTL4 = SELA__XT1CLK; // IMPORTANT. Select ACLK = XT1 = 32768Hz
}
void LCD_Config(void) // MSP430FR4133
{
uint8_t ui8Cnt;
uint8_t *pLCD = (uint8_t *)&LCDM0;
for (ui8Cnt = 13; ui8Cnt > 0; ui8Cnt--) // Clear LCD memory
*pLCD++ = 0x00; // CLR LCD
SYSCFG2 |= LCDPCTL; // R13/R23/R33/LCDC1/LCDC2 pins selected 设置 LCD功耗
LCDPCTL0 = 0xFFFF;
LCDPCTL1 = 0x01FF; //设置 LCD管脚 L0~L24 pins selected
LCDVCTL = LCDSELVDD + LCDCPEN; // Mode 2 设置 降低LCD 功耗 片上电荷泵
LCDCSSEL0 = 0x000F; // 设置 公共极 COM0~3
LCDCSSEL1 = 0x0000;
LCDM0 = 0x21; // L0 = COM0, L1 = COM1
LCDM1 = 0x84;
LCDCTL0 |= LCD4MUX + LCDLP + LCDON; // 打开LCD: 4-mux 模式
}
一周热门 更多>