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 Embedded C for MSP43X - Where

Other Parts Discussed in Thread: MSPWARE

I am just starting to learn about the MSP432. I have worked with the MSP430 for quite a few years, but using assembler only. I can find many references to C programming but little on the low level stuff, like setting port pin directions, enabling interrupts, setting a low/high on an output pin, etc. Does TI have a document like this anywhere or do I have to plough through all the exambles?

Thanks

Peter

  • Hi PeterG!

    Writing C code for the MSP43x processor isn't very difficult. It is normal C, so any online manual / tutorial or a good book is helpful for the basic C part. The MSP43x specific part is only using the registers of the processor. And using the registers is nothing else than setting or clearing individual bits. The compilers have .h files for each processor that contain #defines for the registers - these match the names from the user's guide, but this is the same when writing code in assembler. The code examples for the MSP432P401R provided by TI are a good point to start from. And here is another good tutorial - look at tutorial 3 Flipping Bits - it describes the different bitwise operations that are necessary to set or clear bits in registers. The technical reference manual for the MSP432P401R contains all information about the modules and the registers. When moving from the MSP430 to the MSP432, the MSP432 Platform Porting Guide might be interesting as well since the interrupt handling is slightly different - the document describes the differences.

    Dennis

  • As I have gone from Asm to C this year, unless you are using stuff like mspware libraries, it's still the same.
    mov is replaced with = and your start with the destination so that order is reversed.

    Here I define the what you would use bit, bic, bis and xor in asm.
    #define read &
    #define clear &= ~  // the ~ have priority so if it's more than one item after it use(), like ~(BIT1 | BIT3)
    #define set |=
    #define toggle ^=

    And all these "void" is just to show nothing coming back and/or nothing going in.
    Kind of annoying that you have to predefine all subroutines, and having to put a bunch of extern... in common.h for global reach etc.
     
    The compiler handles variables for you. It will sort them init to zero or init a value, then it will append to your code a cmemclr and cmemcopy to initialize these on reset. You can override it with __low_level_init() if needed.

    typedef structures is nice as you get help with field names when you type the . in

  • Thanks for the post. I am way down on the learning curve but moving up!

    Peter

**Attention** This is a public forum