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.

ULP advisor & unused pin termination

Other Parts Discussed in Thread: TEST2

1. It says to terminate pins by setting pin as output by setting P1DIR=0xff; (one of the method)

& then sending zero on it .

Then safer method is to left pin unconnected ?

2. Count down in loops, can someone shed more light on it.

3. I have a program where my required variable can be stored in 14 bits also. So I have done

struct
{
    unsigned  vol_det : 14;
    unsigned  vol_rel : 14;
}over;

Other method is to use unsigned int. 16 bits.

Which one's more efficient & power saver. :)

4. Usually MCU gives current in uA/MHZ.

  • 1. That drives the pin to a fixed low level. That allows unconnected pins that can be used later by soldering a wire or attach a probe on it if necessary. Tied down pins are lost.

    2. Here assembly comes to help - a usual loop is done by counting down in assembly language instead of counting up. When counting down you have only an conditional jump if counter is zero (jnz). When counting up, you must check if upper limit is reached - you need to do a substraction of the counter and the limit and after that follows the conditional jump. Some clock cycles to spare.

    3. I would use 16 bit integers as the msp can operate on them directly and with the struct of 28 bits you still need 2 bytes to store the values anyway.

  • Jan Kesten said:
    Tied down pins are lost.

    In addition to this, unconnected pins can catch radio waves, causing unnecessary cross-currents int he input drivers. CMOS inputs tend to draw significant current when the input voltage is near the input threshold voltage.
    That's the reason why unuse dpins shpould be attached GND level, whetehr by external means or by  internal pulldowns.

    Jan Kesten said:
    Some clock cycles to spare.

    And also some bytes of code space. As no comparison is necessary and therefore no compare command.

    For 4., I don't exactly know what the question is. Probably why there is no µA/Mhz rating fo the MSPs. If so, the answer is that such a rating is only meaningful for MCUs with a fixed operating frequency.
    Current consumption and frequency don't scale linearly. Current consumption consists of two parts. A static current and a dynamic current. While the satic curren tis more or less constant for all operating frequencies, the dynamic current rises with the operating frequency.
    Also, the dynamic current depends on teh actualyl executed instrucitons. Instructions that require accessing the flash for instruction, addresses, parameters and maybe values, draw more than those which pull the parameters and values from the constant generator or ram or hardware registers. And if the code is executed from RAM, things are different again. Also, the supply voltage has some influence too. Many other MCUs only have a fixed operating voltage.
    So only a few typical values are given for specific combinations/frequencies. Which do not linearly scale with frequency or operating voltage, so a single index value like µA/MHz is impossible to give.

  • 1. So unused pins should be

           a. Set as ouput dircetion

            b.  Set driver to zero

            c. Connected to gnd by external means, is it?

    2. Similarly if a single flag bit, is used, char is more sufficient instead of unsigned bit :1 . IS it? DO CCS support bit variable also?

  • Either set to output direction with low output, or set to input with internal pulldown, or set to input with external pulldown.

    Since external pulldown requires routing and maybe even a resistor (a direct GND connection is not a good idea during development, as accidental programming of the pin as high output will cause high currents then), and internal pullups weren't available on the 1x family, a low output and no external connection was the preferred option.

  • 1, As Jan has said, it better to represent & work on unsigned int

    struct
    {
        unsigned  vol_det : 14;
        unsigned  vol_rel : 14;
    }over;

    Other method is to use unsigned int. 16 bits.

    Which one's more efficient & power saver. :)

    2. Similarly,

    struct
    {
        unsigned  vol_det : 1;
        unsigned  vol_rel : 1;
    }over;

    Other method is to use unsigned char 8 bits.

    Which one's more efficient & power saver. :).

    3. Do CCS has bit datatype also?

  • Hi,

    quite simple answer:

    1. two unsigned 16bit integers are better, there are instructions to operate on them directly and the same goes for fetching them from memory. Structs are maybe more dense packed, but need unpacking which costs extra cycles (and instructions)

    2. not done a compile and disassembly test I would suspect a single unsigned char with appropriate bit instructions will be faster (or the compiler is clever enough since it is a bitfield)

    3. Bits are not really useful since the smallest piece of data which can be handled by the cpu is a byte. But you can use bit fields as in 2. 

  • FYI, I'm going to add a Wiki link that documents ULP advisor rules:

    http://processors.wiki.ti.com/index.php/ULP_Advisor 

  • Hi, I want to know which one would be more efficient:

    1. struct
      {
        unsigned  vol : 1;
      }over;

    2. Other method is to use unsigned char 8 bits.

    unsigned char over_vol;

    Which one's more efficient & power saver. :). Which one should I use. 

  • Hi!

    If you need to save power, use unsigned chars, no structs. Structs almost always introduce overhead for managing them but they can save space. I've done a (very) simple test to illustrate this:

    1. test1 is a simple program with your single bit struct
    2. test2 is a simple program with your single char instead
    3. test3 and test4 are the same but have 24 values or 3 structs each
    Everything complied with out any optimization done:
     text data bss dec hex filename
    120 0 0 120 78 test1.elf
    112 0 0 112 70 test2.elf
    696 0 0 696 2b8 test3.elf
    240 0 0 240 f0 test4.elf
    You can see, 1 compared to 2, the second one takes less code space and may run faster. Compared 3 and 4 the effect is much more visible, structs cause nearly 3 times more code. But that is without any compiler optimization (when on, my complete main will go away since I did not use any of the variables). 
    But another thing is to check (and I haven't done so far) how often reads from memory are necessary which are slower than from registers and do a runtime calculation by that. 
  • Some tip for an another ULP rule.

    Internal reference voltage for example at sigma delta A/D  should be switched off, before entering LPM, otherwise current which goes trough is about 180 uA.

  • Martin Fridrich said:
    Internal reference voltage for example at sigma delta A/D  should be switched off, before entering LPM

    This is, however, a "weak rule", since enabling the reference when the sample needs to be taken, will require some time, causing additional current consumption due to waiting time.
    It's the engineers responsibility to weight the benefit of disablign it to the drawback of additional timing efforts (and the current consumption it requires).

    Especially if the delay between two samples is shorter than the reference settlign time, disabling the reference is completely useless.

  • Fully agree with: Especially if the delay between two samples is shorter than the reference settlign time, disabling the reference is completely useless.

    But ULP at this moment has also another weak rules like started with - Avoid

    For example MSP430F20x3 has Iref between 190 -280 uA (by Datasheet). So than could be better to play with on/off reference than with LPM. Lets say with measurement freq. <100Hz for Sigma Delta and for 10 bit AD < 16kHz. ( Tsettle*2)^-1)

    ULP is here for less advanced engineers :-) Experts already has enough knowledge about low power technics. For constant current 190 uA (Sigma delta) you need 1,6644 Ah battery tu run reference for 1 year. And MSP430 is here mainly for battery operations. For 10 Bit AD at corresponding familly Iref current without current buffer is 0,25 mA. So for one year operation you need 2,19 Ah battery for one year. If I compare impacts then I see the rule ULP 1.1 Ensure LPM usage could be less important than if detected in code usage of Internall reference - to Create Rule - Ensure switching off refference when possible (in explanation of this rule can be written check the Settle time for reference) 
     

  • What should we do with unused SD pins? Ground or leave it open? Also is it possible to connect on gauge to several SD input to get better number?

  • Masood G. Bashiri said:
    What should we do with unused SD pins? Ground or leave it open?

    If it is a plain analog SD input pin (no digital circuitry), then it shouldn't make much of a difference. The grounding is only required on digital pins because of their digital input stage which doesn't like input voltages in the range of the threshold voltages (which happens on open pins due to the high impedance).

    If the pins are only SD inputs and nothing else, I think they can be left unconnected. Unless you want to 'use' them as guard pins, to suppress crosstalk or stray antenna effects on their neighbor pins.

**Attention** This is a public forum