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.

Learning programming msp430.

I am new to programming msp430. As I read through sample C code, I see lines similar to the ones below. Which book/manual/tutorial explains all these constants and variables and how to use them? How do you go about learning and understanding these? I have the Launchpad, and I watched the videos and read though the pdf file, but still no way I can come up with code like the one below on my own. What am I missing?

Sample C code:

...

_BIC_SR(OSCOFF); // Enable the LFXT1 crystal oscillator
UCSCTL6 &= (~XTS); // Select Low-frequency mode. XCAP bits define the capacitance at the XIN and XOUT pins.
UCSCTL6 |= (XCAP0); // Set XCAP0
UCSCTL6 |= (XCAP1); // Set XCAP1

...

  • All the mnemonics are in the uC header file, at the top of the code it would appears a line like that: #include "msp430XXXX.h". If you open this file you will see all the mnemonics.

    But if you want to know what they mean and how you use them, you have to get the users' guide of your uC family, and understand how the peripheral modules work and how they can be configured.

    If you have never worked with uC, it is normal that thing like register and mnemonics seem strange, but using mnemonics, it is more comfortable write register, and it avoids possible errors like: "I want to set the BIT1 of the register, and I write 0x01(it sets BIT0) instead of 0x02." Moreover, it is easier to read for another or even for  Louis from the future :).

    As for "&=" or "|=", they are C operators, so you can get a explanation in any C guide.

  • I think that a good book is MSP430 Microcontroller basics by John Davies

  • Thanks "Is T da S" for the answer. Actually I am quite familiar with C, and some what familia with uControllers. I guess I should have stated the question differently. I think  my frustration is with the amount of effort needed to get familiar with all the registers and the various values they need to be set to in order to perform various functions. So, even though the application I have in mind might not be that complicated, yet I have to go through tons of info to accomplish the rather small task.

    My question should have been "How do you go about learning all that?" Is reading hundreds of pages the only way?

    I played a little bit with Grace, and I think it may help.

  • "A journey of a thousand miles begins with a single step".

    The only way, at least I know it, is the loop: "reading, writing code,testing and debugging" until it works. If you know something about uC and interrupts, you have a big step done.
    I started with these uC five months ago, and I am still semi noob, although I am able to work with external interrupts, timers, ADC, serial communication, etc. So, the only recommendation I can give you is reading user guide, and go testing module by module, something will take you more time in some modules than in others. The available code examples are very useful to do your first attempts, and understand how the module works. This way is that I have used to learn and make  the uC works, an by now, it seems that it works :). Moreover, it would be useful to have some electrical/electronic knowledge, since in the uC, not all is coding.
    If i have some language error sorry, I cannot check it all the time I post.
  • Thanks again "Is T da S". I think I am spoilt using an IDE like Eclipse with Java. You type an object name and the code completion feature shows all the methods and constants available for that object, with help and explanation at your finger tip. I agree with you,   "A journey of a thousand miles begins with a single step". 

  • Louis said:
    "A journey of a thousand miles begins with a single step"

    That's right. However, we are all used to assuem this first step will lead us to the next plane that brings us to the destination. (use of libraries and frameworks). However, for projects as small as going to the mailbox and checking the mail, using a plane surely wouldn't be a good idea.

    This is why microcontroller development is different, even if you know the language (C/ASM).

    PC development priorities are: Fast development, low development cost, high 'whistles and bells' factor. Let the customer buy an expensive PC for runnign the crappy-coded slow and bloated software. And if a hourglass appears, well, people are used to it.
    Microcontroller priorities are usually: low produciton cost (including hardware), seamless and efficient operation. Teh customer buys teh whoel thing together, so it must be cheap in mass production.And higher development costs are usually acceptable if they reduce the production costs because of smaller code (cheaper processor with less flash) etc.

    I agree that some things like register names and bit/option names as tooltips would be nice. But this is impossible for a reason.

    While an IDE can list the members of a struct if the struct is known, it cannot determine whether some defines belong to this or that register. There are lots of aliases and ambiguous relations. No IDE can sort this out by analyzing the source files.
    The IDE would have to be programmed by separate macros that provide the needed information. Differently for each MSP.
    I think there are some 3rd party tools that offer exactly this for eclipse  (not MSP specific). But then still the data has to be collected.
    Still the multiple options (XCAP0, XCAP_1, XCAP__6pF, all three the same under certain circumstances) will make it difficult to make any use of this information when available.

    But there is an approach of a different kind: GRACE. It offers an UI for configuration and produces the proper config code, including registers and settings as required.

    Well, I like it as it is. If everything were just a fingertip away, there wouldn't be a place for a guru :)

**Attention** This is a public forum