Other Parts Discussed in Thread: ADS1248
Tool/software: WEBENCH® Design Tools
Hi Team,
As per my product requirement i want to control the power consumption of micro controller.
Please suggest me to how to enable the low power modes(LPM0,1,2,3). Please check the code base and help me to get out off this issue.
Please check attached file for reference.. All peripherals using SMCLK
void configureHardware(void) { //Initialize RTC RtcSettings(); //Basic Clock Settings SYSINIT_Init_Micro(); //DELAY 1ms TB0.0 InitializeSystemTimer(); // Initialize timer pool timer_pool_init(); //5mSEC TRIGGER TA0.0 Initialize5msTimer_start(); //all modules gpio configurations AllModuleGpioConfig(); //rs232 run machine initializeUSCI_B1_M_Lcd(void); //Internal ADC ADC_Initialize(); I2CInitialization(); } void RtcSettings(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT while(BAKCTL & LOCKBAK) // Unlock XT1 pins for operation BAKCTL &= ~(LOCKBAK); UCSCTL6 &= ~(XT1OFF); // XT1 On UCSCTL6 |= XCAP_3; // Internal load cap // Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag // Configure RTC_B //RTCCTL01 |= RTCRDYIE + RTCBCD + RTCHOLD; // BCD mode, RTC hold, enable RTC read ready interrupt RTCCTL01 |= RTCRDYIE + RTCTEVIE + RTC_B_FORMAT_BINARY + RTCHOLD; // BCD mode, RTC hold, enable RTC read ready interrupt // RTCYEAR = 0x2012; // Year = 0x2011 // RTCMON = 0x06; // Month = 0x06 = June // RTCDAY = 0x22; // Day = 0x22 = 22nd // RTCDOW = 0x05; // Day of week = 0x05 = Friday // RTCHOUR = 0x11; // Hour = 0x11 //RTCMIN = 0x59; // Minute = 0x59 //RTCSEC = 0x45; // Seconds = 0x45 RTCCTL01 &= ~(RTCHOLD); // Start RTC calendar mode // __bis_SR_register(GIE); // Enter LPM3 mode with interrupts __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 mode with interrupts // enabled __no_operation(); } void SYSINIT_Init_Micro(void) { //Stop Watch Dog Timer............ WDT_A_hold(WDT_A_BASE); /* PMM_setVCore(PMM_CORE_LEVEL_1); //DEFAULT 0 DLY_US(1000); PMM_setVCore(PMM_CORE_LEVEL_2); //DEFAULT 0 DLY_US(1000);*/ PMM_setVCore(PMM_CORE_LEVEL_3); //DEFAULT 0 DLY_US(1000); //Set DCO FLL reference = REFO UCS_initClockSignal( UCS_FLLREF, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1 ); //Set ACLK = REFO UCS_initClockSignal(UCS_ACLK, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1 ); //Set Ratio and Desired MCLK Frequency and initialize DCO UCS_initFLLSettle(UCS_MCLK_DESIRED_FREQUENCY_IN_KHZ, UCS_MCLK_FLLREF_RATIO ); //Verify if the Clock settings are as expected clockValue = UCS_getSMCLK(); clockValue = UCS_getMCLK(); clockValue = UCS_getACLK(); } void InitializeSystemTimer(void) { TB0EX0 = 6; // CCR0 interrupt enabled TB0CCTL0 = CCIE; TB0CCR0 = TIMER_B0_RELOAD; // SMCLK, continuous mode, clear TAR TB0CTL = TBSSEL_2 | MC_2 | TBCLR; __bis_SR_register(GIE); // Enter LPM0, enable interrupts } void Initialize5msTimer_start(void) { //Start timer in continuous mode sourced by SMCLK Timer_A_initContinuousModeParam initContParam = {0}; initContParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK; initContParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_7; initContParam.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE; // ENABLE initContParam.timerClear = TIMER_A_DO_CLEAR; initContParam.startTimer = false; Timer_A_initContinuousMode(TIMER_A0_BASE, &initContParam); //Initiaze compare mode Timer_A_clearCaptureCompareInterrupt(TIMER_A0_BASE,TIMER_A_CAPTURECOMPARE_REGISTER_0); Timer_A_initCompareModeParam initCompParam = {0}; initCompParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_0; initCompParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE; initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_OUTBITVALUE; initCompParam.compareValue = TIMER_A0_RELOAD; Timer_A_initCompareMode(TIMER_A0_BASE, &initCompParam); Timer_A_startCounter(TIMER_A0_BASE,TIMER_A_CONTINUOUS_MODE); __bis_SR_register(GIE); // Enter LPM0 w/ interrupt } void initializeUSCI_B1_M_Lcd(void) { #define CTRL_OPERATING_FREQ 20000000 // USER CONFIGURABLE #define SPI_CLK_186KHZ 186000 #define SPI_CLK_1MHZ 1000000 #define SPI_CLK_2MHZ 2000000 #define SPI_CLK_4MHZ 4000000 #define SPI_CLK_8MHZ 8000000 #define SPI_CLK_20MHZ 20000000 MLCD_CS_OUT_PIN_CONFIG(); //MLCD Chip select pin configured as a output MLCD_CS_HIGH();// CS HIGH MLCD_SPI_PERIPH_CONFIG(); //spi peripheral UCB0CTL0 = 0X09; //lsb first 8bit data ,mode 0, synchronous , master mode, 3pin spi UCB0CTL1 = 0X80; //fix smclk UCB0BR0 = (CTRL_OPERATING_FREQ/(SPI_CLK_2MHZ)); //2MHZ UCB0BR1 = 0; USCI_B_SPI_enable(USCI_B0_BASE); __bis_SR_register(GIE); } void ADC_Initialize(void) { ADC_12_BIT_PERIPH_PIN_CONFIG(); //P6SEL = 0x03; // Set P6.3 as Peripheral Module - Enable A/D channel inputs P6SEL = 0x03; ADC12CTL0 = ADC12ON + ADC12MSC + ADC12SHT0_2; // Turn on ADC12, set sampling time - 16 cycles ADC12CTL1 = 0x021A;//ADC12SHP + ADC12CONSEQ_1; // Use sampling timer, single sequence, smclk ADC12MCTL0 = ADC12INCH_3 + ADC12EOS; // ref+=AVcc, channel = A0 ADC12CTL0 |= ADC12ENC; // Enable conversions } void I2CInitialization() { UCB2CTL0 = 0X0F; UCB2CTL1 = 0XC0; //smclk UCB2BR0 = 50; // Set I2C master speed 50 gives approx 400Khz clock at 20Mhz UCB2BR1 = 0; // Set I2C master speed }