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.

Hard to examples for msp430g2231

Other Parts Discussed in Thread: MSP430G2231, MSP430F2101

I've recently been given an assignment to make a led to blink. I found the chip, msp430g223, it has all the features we need. Unfortunately all preexisting projects are for everything else. Specifically, the LED flashing project is for a msp430f21x1. Of course at the Make/build rejected the use.

Now for the record I do some programming, C/C#, but not for embedded systems so this particular IDE you guys use is really difficult as far as learning curve. I';ve read all the "ccsv.4 start here".

Second question, what's this c2000. Is it applicable to the msp430?

Any suggestions to import a compliant project or method to build a project from  other chip types for a msp430g2231.

 

thanks

L.

  • N F said:
    Now for the record I do some programming, C/C#, but not for embedded systems

    The language is still C(++), yet there is a generic difference - youshouldn't program an MC like a PC. YOu have limited resource, so things like style and object orientation have to second the need of efficiency, small size and speed. An MC that shows the user an hourglass for some seconds is a piece of crap, on a PC this is common. And a 'hello world' program of some megabytes size is too common on a PC and completely useless on an MC.

    Besides this generic difference in programming style, the main difference to a PC is the existence of integrated hardware modules. Where on a PC you'd write a driver and pass parameters etc, you'll simply access the hardware functions like variables, which have a 'side effect' when being read or written.

    Now for the differences between different MSPs: the over 300 different MSPs have different ram size, different flash size and different number and type of hardware modules.
    Including the correct header file defines all register variables that are present on this particular MSP. Setting the correct MSP type in teh project settings tells the linker where this specific one has its memory areas.

    So

    • start a new project for your MSP type
    • copy over the source file and add it to the project
    • change the include at the top of the source file to include the proper header for your MSP

    Then the different hardware capabilities need to be addressed.

    Foe example (the important one for the blinking LED), all MSP have digital ports. At least a Port 1, but some have up to Port10. Each port is directly connected to a physical pin. Some have alternative funcitons on the same pin.
    However, the ports (independetly of number and physical pin) work all the same on all MSPs:

    You have a direction register where you can set the directipon of each pin by setting a bit in this register, then there is an input register that returns the current state of the pin, also one bit per pin, and a register for the output level (if it is configured as output). Again one bit per pin.

    All you have to do is to identify the used pin in teh example and where you want it instead on your processor. And change the access to the registers accordingly.

    It helps to have the datasheets for both processors and the 2x family users guide (which contains the register descriptions).

    Example:

    P1DIR |= 0x01; // sets the port pin P1.0 to output
    P1OUT|=0x01; // sets the output signal on P1.0 to high
    P1OUT&=~0x01; // sets it back to low.
    P1OUT^=0x01; // toggles the pin.
    For pin P1.1, use 0x02 etc. And |= is used to not touch and alter the configuration of the other 7 pins (just in case a different part of the code has already configured them).

  • L  here. I looked into the file, the .c, and changed the #include "msp430f2101.h" to #include "msp430g22311.h". Duh, keep the basics.

    I apologize to anyone who may have answered. Please no replies to this. And I read up on this C2000.

    In the future I'll do more research before a question.

     

**Attention** This is a public forum