crastonhill's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
29 (0.06 per day)
Joined:
21-January 12
Profile Views:
133
Last Active:
User is offline Mar 03 2012 04:44 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   crastonhill has not set their status

Posts I've Made

  1. In Topic: MSP430FG4618 experiments board....battery monitor

    Posted 19 Feb 2012

    Quote

    What is ADC12MCTL0 = SREF_1 + INCH_11; actually doing?


    SREF_1 ....makes VR+=Vref+ and VR_= Avss..(in my case zero)
    INCH_11.....is the voltage divider initiation I was talking about...(AVCC - AVss)/2
    this what this statement does??

    Quote

    Your "battery" is connected to where?

    the battery is connected to AVCC and Avss(ground)

    http://www.ti.com/li...9f/slau049f.pdf
    Chapter 17 of this user guide....page 17-3 for circuit diagram for internal ADC of the microcontroller
    page 17-25 for ADC12MCTL definition
  2. In Topic: MSP430FG4618 experiments board....battery monitor

    Posted 19 Feb 2012

    Yes . The hardware is the same one that I m using...

    well...I have seen the example codes....But where exactly do u think a while statement is needed??


    The LCD information can all be found here..in these two links

    http://www.softbaugh...ecification.pdf
    http://www.softbaugh...rPartNo=SBLCDA4

    http://cnx.org/conte...test/LCD_defs.h
    This is the header file I am using....in my code...Thats wher BAT_FULL and all variables comes from

    Although I doubt that I have made any mistakes with LCD configuration. I made a whole alarm clock on this
    I think the settings should be fine....

    cheers

    Forgot to tell I use the ADC12_07 example code as reference for this particular code...!
  3. In Topic: MSP430FG4618 experiments board....battery monitor

    Posted 19 Feb 2012

    Well it doesnt fix the problem... It displays the full voltage symbol...however..it doesnt respond to the voltage change...i mean when voltage falls below 2.5 v...it should display low battery symbol.

    I dont think i need the while loop...because ADC12CTL0 = REFON + REF2_5V + ADC12ON + SHT0_8+ MSC......the MSC command ensures that the next conversion should be done automatically after another...so in case of a new conversion..interrupt routine will be called...is it not??
  4. In Topic: MSP430FG4618 experiments board....battery monitor

    Posted 19 Feb 2012

    Quote

    Where are you displaying anything on the LCD?

    if (BAT_VOLT>=1.25){
    BAT_FULL;
    }else{
    BAT_50;}
    BAT_FULL and BAT_50....these are variables defined in LCD_defs.h for displaying symbols on LCD screen

    Quote

    What type of variable is BAT_VOLT?

    Yes.. just realised that...I will change it to double as it will take a fraction

    Quote

    What happens to your program after __bis_SR_register(LPM0_bits);? And what is this line doing? What is LPM0_bits?

    C compilers do not allow to get access to the CPU control registers. On MSP430 the CPU Register R2 is used as the Status Register (SR).
    There are bits within the SR that allows to configure the chip into its Low Power Modes and there is the General Interrupt Enable (GIE) bit.
    So if you want to change either the LPM mode or set/clear the GIE bit you use an intrinsic function of the C compiler - that's the __bis_SR_register() function.

    This line just configures the system to a low power mode ...definitions are defined in datasheet.. It goes into Low power mode with the interrupt.
    code with changes!!

    #include  <msp430fg4618.h>
    #include <stdint.h>
    #include<intrinsics.h> //For add_bcd_short function to be used
    #include  "LCD_defs.h" // P7_A1...P1_A0....all defined here
    unsigned int ADCValue;
    unsigned double BAT_VOLT;
    void LCD_all_off(void);
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    
      //LCD_A S0-S21 configuration
                LCDAPCTL0 = LCDS24 | LCDS20 | LCDS16 | LCDS12 | LCDS8 | LCDS4;
    
                // LCD_A configuration
                LCDACTL = LCDFREQ_192 | LCD4MUX | LCDSON | LCDON;   // (ACLK = 32768)/192, 4-mux LCD, LCD_A on, Segments on
                LCDAVCTL0 = LCDCPEN;                                // Charge pump enable
                LCDAVCTL1 = VLCD_3_44;
                LCD_all_off();
    
     // ADC CONFIGURATION
    
      P6SEL |= 0x01;                            // Enable A/D channel A0
      //ADC12CTL0 = ADC12ON + SHT0_8 + MSC;       // Turn on ADC12, set sampling time
      ADC12CTL0 = REFON + REF2_5V + ADC12ON + SHT0_8+ MSC;//reference used 2.5 v , MSC= multiple sample and conversion starts another
      	  	  	  	  	  	  	  	  	  	  	  	  	  //conversions as one ends// SHT0_8 ..256 cycles of clock
      ADC12CTL1 = SHP + CONSEQ_2;               // Use sampling timer, set mode//repeat single channel conversions
      ADC12IE = 0x01;                           // Enable ADC12IFG.0
      ADC12CTL0 |= ENC; 						 // Enable conversions
      ADC12MCTL0=SREF_1+INCH_11;                    // selecting reference and channel 11(( Avcc-Avss)/2)
      __enable_interrupt();                     // Enable interrupts
      ADC12CTL0 |= ADC12SC;                     // Start conversion
     for(;;)/>{   
     __bis_SR_register(LPM3_bits + GIE);
     }
    }
    
    #pragma vector = ADC12_VECTOR
    __interrupt void ADC12_ISR(void)
    {
    ADCValue= ADC12MEM0;  // Move  conversion result, IFG is cleared
    BAT_VOLT= (unsigned double)((ADCValue)*(2.5/4095)) ;   //coverting the value from ADC into voltage
    
    if (BAT_VOLT>=1.25){        //using voltage divide 2.5/2 =1.25 (not sure abt this bit??)
    	BAT_FULL;             // Any battery value above 2.5 gives symbol battery full
    }else{
    		BAT_50;}              //any battery value below 2.5 gives low battery symbol(BAT_50 or BAT_LOW...same thing defined)
    
    	}
    
    
    //LCD clear routine
    void LCD_all_off(void)
    {
     LCDM2 = 0x00;
     LCDM3 = 0x00;
     LCDM4 = 0x00;
     LCDM5 = 0x00;
     LCDM6 = 0x00;
     LCDM7 = 0x00;
     LCDM8 = 0x00;
     LCDM9 = 0x00;
     LCDM10 = 0x00;
     LCDM11 = 0x00;
     LCDM12 = 0x00;
     LCDM13 = 0x00;
    }
    
    
    
    


    sorry changed it....the type is double not unsigned double...!!
  5. In Topic: MSP430FG4618 experiments board....battery monitor

    Posted 19 Feb 2012

    Ok.. I have changed the code totally...to make it more simpler... Few notes ....ADC_value defined should be the value i will get after conversion considering the internal voltage divider of the ADC(ADC12MCTL0=SREF_1+INCH_11; )....now when i get that converted value...as you said i can convert that to voltage...and then use it to find the status of the battery... and then make the comparison..... (BAT_VOLT) defines that...Then that can be used for comparison...!However, still the program just jumps to the BAT_LOW..when ISR is called,...not sure what it is doing??thanks for your time

    
    #include  <msp430fg4618.h>
    #include <stdint.h>
    #include<intrinsics.h> //For add_bcd_short function to be used
    #include  "LCD_defs.h" // P7_A1...P1_A0....all defined here
    unsigned int ADCValue;
    unsigned int BAT_VOLT;
    void LCD_all_off(void);
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    
      //LCD_A S0-S21 configuration
                LCDAPCTL0 = LCDS24 | LCDS20 | LCDS16 | LCDS12 | LCDS8 | LCDS4;
    
                // LCD_A configuration
                LCDACTL = LCDFREQ_192 | LCD4MUX | LCDSON | LCDON;   // (ACLK = 32768)/192, 4-mux LCD, LCD_A on, Segments on
                LCDAVCTL0 = LCDCPEN;                                // Charge pump enable
                LCDAVCTL1 = VLCD_3_44;
                LCD_all_off();
    
     // ADC CONFIGURATION
    
      P6SEL |= 0x01;                            // Enable A/D channel A0
      //ADC12CTL0 = ADC12ON + SHT0_8 + MSC;       // Turn on ADC12, set sampling time
      ADC12CTL0 = REFON + REF2_5V + ADC12ON + SHT0_8+ MSC;//reference used 2.5 v , MSC= multiple sample and conversion starts another
      	  	  	  	  	  	  	  	  	  	  	  	  	  //conversions as one ends// SHT0_8 ..256 cycles of clock
      ADC12CTL1 = SHP + CONSEQ_2;               // Use sampling timer, set mode//repeat single channel conversions
      ADC12IE = 0x01;                           // Enable ADC12IFG.0
      ADC12CTL0 |= ENC; 						 // Enable conversions
      ADC12MCTL0=SREF_1+INCH_11;                    // selecting reference and channel 11(( Avcc-Avss)/2)
      __enable_interrupt();                     // Enable interrupts
      ADC12CTL0 |= ADC12SC;                     // Start conversion
      __bis_SR_register(LPM0_bits);             // LPM0
    }
    
    #pragma vector = ADC12_VECTOR
    __interrupt void ADC12_ISR(void)
    {
    ADCValue= ADC12MEM0;  // Move  conversion result, IFG is cleared
    BAT_VOLT= (ADCValue)*(2.5/4095) ;   //coverting the value from ADC into voltage
    
    if (BAT_VOLT>=1.25){        //using voltage divide 2.5/2 =1.25 (not sure abt this bit??)
    	BAT_FULL;             // Any battery value above 2.5 gives symbol battery full
    }else{
    		BAT_50;}              //any battery value below 2.5 gives low battery symbol(BAT_50 or BAT_LOW...same thing defined)
    
    	}
    
    
    //LCD clear routine
    void LCD_all_off(void)
    {
     LCDM2 = 0x00;
     LCDM3 = 0x00;
     LCDM4 = 0x00;
     LCDM5 = 0x00;
     LCDM6 = 0x00;
     LCDM7 = 0x00;
     LCDM8 = 0x00;
     LCDM9 = 0x00;
     LCDM10 = 0x00;
     LCDM11 = 0x00;
     LCDM12 = 0x00;
     LCDM13 = 0x00;
    }
    
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

crastonhill hasn't added any friends yet.

Comments

crastonhill has no profile comments yet. Why not say hello?