This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Enabling an input pin

Hi all,

I am working with the MSP430 eZ430-RF2500.  I am new to the products and I'm not very savy with it.  What I am trying to do is to use the original "sensor monitor source code v1.5 with IAR" and edit it to instead of reading the temperature, read a voltage from a passive CT and transmit that data back to the Access point.  So, what i have done is set access points and end devices with not to much trouble. Now i am trying to enable an input pin that can be used for my devices and that is where the problem is encountered. I want to use A1  input and am using the code as follows

 

  P2DIR = 0 ;           // I can see from page 60 of the msp2274 pdf that these pins have to be reconfigured in order to bias the gates
  P2REN |= 0 ;
  P2OUT = 0;

"other source code"

    ADC10AE0 |= 0x02 ;                                       // enable for the pin selects
    ADC10CTL1 = INCH_1;                               // This is to call my input pin
    ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;
    __delay_cycles(350);                   
    ADC10CTL0 |= ENC + ADC10SC;          
    __bis_SR_register(LPM0_bits + GIE);   
    results[0] = ADC10MEM;
    ADC10CTL0 &= ~ENC;

So, what is my problem with the code? Any help would be greatly appreciated.

  • Hi,
    well, at least the instruction  P2REN |= 0; is not working... I assume your attention is to clear all bits from P2REN.

    Note that if you do a

            A |= B;  

    this means in C:

            A = A | B;

    and the "|" stands for a bitwise OR.

    So usually you will see this in MSP430 code to set the bits that are '1' within the parameter B. All other bits will not be changed.

    Maybe you should also take a look into the MSP430 Code Examples. You find it on the MSP430 Homepage:

    www.ti.com/msp430

    Click on the tap "Code Examples" and look for the MSP430F20xx, MSP430G2xx.

    I think the file "msp430x20x2_adc10_01.c" within the zip file could be interesting for you...

    Regards.

  • What is the problem you have?  Invalid readings...?  Crashes...?  It is hard to suggest a solution without knowledge of the actual problem...

  • The problem is I don't really know what I am doing.  I want to use the sensor monitor v1.5 program and replace the temperature sensor input with my own from a function generator.  My problem is I dont know how to setup an pin to recieve data. 

    I can offer up the links to the orignal code and not the snippets that I have more or less rendered useless. 

  • As far as the code that I have. the original works fine (debug and all).  I'm just struggling with altering it.

  • I'm not sure what you mean about biasing the gates.  To measure a voltage input at pin A1 in place of the internal temperature sensor you need to set the AE0 bit1 and then change the source channel from INCH_10 to INCH_1.  You have done this already.  You may also need to adjust the SHTx and ADC10DIVx to ensure sufficient sample/hold time to make an accurate measurement depending upon the input resistance of the voltage source.

    Unless you have changed TACCR0, the device should now sample A1 input at approx 1Hz frequency.  The measured range will be 0-1.5V but will probably still be displayed as a temperature value.

     

    What you have already tried should more-or-less work so what's the problem?

  • Thanks Chris.  You hit right in the ball park with your reply.  I had been focus on those particular instruction but could not get them to all set correctly.  From the origianl sensor monitor source code, the following snippets get me where I wanted to be.

        ADC10AE0 |=BIT0;           //Could of used hex but wasn't critical
        ADC10CTL1 = INCH_0 + ADC10DIV_2;       // Temp Sensor ADC10CLK/5
        ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR + REF2_5V;          //Added Ref2_5V to ADC

        degC = (float)results[0] * ((float)25/(float)1024);     //To output to Sensor monitor the exact voltage level I put in

    The code will be dressed to reflect the project later but for now this is it.  I've done plenty of Visual Basic and C++ but this was my first time ever working with firmware. 

    Regards

**Attention** This is a public forum