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.

How to define a 8bit variable in MSP430?

Dear All,

In MSP430, the basic memory size of variable is used 16bit in SDRAM.

How to set a variable which just used 8bit (or 4bit) memory size for saving SDRAM density.

 

 

 

  • Hi Dennis,

    there's no 4-bit data type available by default, but you can use a bitfield to create one by your own. Search the forum for 'bitfield'; there some threads covering this.

    Here's a list of all available data types:

    Kind regards
    aBUGSworstnightmare

    7573.SLAU132E.pdf

     

  • Dennis Tsai said:
    SDRAM

    SDRAM? This ain't a PC . It's simply SRAM. :)
    However, there is no basic memory size.
    The memory of the MSP can be used by byte and word access. However, word access needs to be word aligned (on an even address). Usually, the linker takes care of that, so word or dword variables are not linked to an odd address. Unless you use pointers and type-casting (e.g. to map variables to structs in streamed buffers etc.). Then you'll probably run into trouble.
    However, you can without limitations use variables of the type (unsigned) char which are 8 bit and may be linked to an odd address.

    4 bit variables are not directly supported. You can use bitfields, so the compiler will construct the 4 bit values from a 16 bit storage location. However, bitfields are relatively slow in both, read and write.

    Note that the IAR assembler does not support bitfields on assembly level. So you cannot mix structs that define bitfields in C with assembly functions, at least not in IAR.

  • Thank you for all reply!

**Attention** This is a public forum