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.

Write direct to LCD memory

Other Parts Discussed in Thread: MSP430F6736

MSP430F6736
CCS 5.2

Perhaps I shall qualify for the "stupid question of the week" award with this gem:

Working on a rather sweet setup with 4 phase LCD (8 digits and various symbols).  Rather than map out individual characters I've created a simple algorithm that alters the LCD memory registers of each character position (eg high byte of LCDM1 and low byte of LCDM1 +1) driven by a small char array.  Rather than have a rather annoying switch() statement to determine which character position - and thereby LCDM register - to access, I'd rather just alter the contents of the memory location directly.

It would be ideal to:

volatile unsigned int var_H=LCDM1;
volatile unsigned int var_L=LCMD2;

// or for the F6736:

var_H=0A20;  // 0A20 is LCDM1
var_L=0A21;   //  and LCDM2

and then in a loop:

var_H &=~0xFF;
var_L &=~0xFF;
var_H |= 0xD0 ;
var_L |= 0xFF;

++var_H;
++var_L;

Something so simple as altering memory, but unless I use a defined constant, like

LCDM1 = 0xFF;

my idea fails.

Is there a function for this purpose?

  • Answer to self: You won the award.

    // output 0-9 and A-F
    void LCDMARCH(void)
    {
        char  *mempos_H;
        char  *mempos_L;
        unsigned char i=0;
        unsigned char j=0;
        mempos_H=(char*)       &LCDM1;
        mempos_L= (char*)       &LCDM1;
        ++mempos_L;
        // clear all LCD Memory
        for (j=0;j<19;j++)
        {
            *mempos_H++ &=~0xF0;
        }
        mempos_H=(char*)       &LCDM1;

        for (j=0;j<8;j++)
        {
            for (i=0;i<10;i++)
            {

                *mempos_H &=~0xF0;
                *mempos_L &=~0x0F;
                *mempos_H |=LCDNUMS_map[i]&0xF0;
                *mempos_L |=LCDNUMS_map[i]&0x0F;

                /*mempos_H &=~0xF0;
                mempos_L &=~0x0F;
                mempos_H |=LCDNUMS_map[i]&0xF0;
                mempos_L |=LCDNUMS_map[i]&0x0F;*/
                __delay_cycles(250000);
            }
            for (i=0;i<6;i++)
            {
                *mempos_H &=~0xF0;
                *mempos_L &=~0x0F;
                *mempos_H |=LCDCHARS_map[i]&0xF0;
                *mempos_L |=LCDCHARS_map[i]&0x0F;
                __delay_cycles(250000);
            }
            mempos_L++;
            mempos_H++;
        }

    }

  • Mark Richards said:
    volatile unsigned int var_H=LCDM1;
    [...]
    unless I use a defined constant, [...]my idea fails.

    Well, initializers in variable definitions have to be constants. They are assigned at compiler time.

    As you already discovered, if you want to alter memory locations, you'll have to use pointers.

    volatile unsigned int * var_H = &LCDM1;

    *var_H is then equivalent to LCDM1, but this relation can be altered later by assigning a new memory location to var_H ot by incrementing it. Don't forget that incrementing var_H increments it by the size of its value. Since it is an int *, var_H++ will increment the memory it points to by two bytes.

  • Since it is an int *, var_H++ will increment the memory it points to by two bytes.

    .. which works out perfectly.




**Attention** This is a public forum