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.

mSP430 coding in C

Other Parts Discussed in Thread: MSP430G2553

Hi,

I am trying to write the MSP430 code (MSP430-G2553) in C, and want to use  absoulute hex values insted of symbols. For example for instead of   TACTL = TASSEL_2 + MC_2 + TAIE;  I prefer to write TACTL = 0x0222; in hex, and it works.

Being a digital designer,  I find it more easy and intuitive. But I have trouble with interrupt vector addresses. For example what are the absolute values of the following and similar other vectors in these statements?  #pragma vector = PORT1_VECTOR and #pragma vector = TIMER0_A1_VECTOR ?? Is there any table somewhere? I tried some values from the 430 User guide but did not work !!

Thanks for your time

Inam

  • PORT1_VECTOR is actually 2*2u (or 0x0004). TIMER0_A1_VECTOR is actually 8*2u (or 0x0010).

    You can find them near the end of msp430G2553.h. You can also calculate them yourself as follows:

    Take the interrupt vector address such as 0xFFE4 and 0xFFF0. Subtract 0xFFE0 to get 0x0004 and 0x0010 respectively.

    -- OCY

  • inam rahim said:

    ...  instead of   TACTL = TASSEL_2 + MC_2 + TAIE;  I prefer to write TACTL = 0x0222; in hex, and it works...

    I would love to use: TACTL = ADC10DF | FN5 | Z; There wouldn't be any compilation error and the object code would be the same ;)

  • inam rahim said:
    For example what are the absolute values of the following and similar other vectors in these statements?  #pragma vector = PORT1_VECTOR and #pragma vector = TIMER0_A1_VECTOR ?? Is there any table somewhere? I tried some values from the 430 User guide but did not work !!


    It is in the manual available under "Short Form Description => Interrupt Vector Addresses" (page 11).
    If you use Code Composer Studio it can be found in the header files or more easy when your mark the word "TIMER0_A1_VECTOR" and right mouse click and choose "Open Declaration" in the context menu or shortly press F3.

    The same way you can find nearly all other constants.
    I find it more easy readable to use the symbolic names instead of any hex values.

    The other point is that code with symbolic names is more easy portable to other controllers with another memory layout / other ressource addresses.

  • inam rahim said:
    want to use  absoulute hex values insted of symbols.

    Then don't expect any help in this forum if you encounter problems later.

    The use of (properly defined) symbols makes the code more readable, tells your intention and prevents the accidental use of a wrong binary value.

    inam rahim said:
    Being a digital designer,  I find it more easy and intuitive.

    Well,what is more easy and intuitive than using a symbol whose name matches its purpose? In a digital circuit design, do you use pictures of ICs with pin numbers for the schematics? Or do you use gate symbols etc.? In the first case, I surely wouldn't hire you.

**Attention** This is a public forum