1. 程式人生 > >MSP430 LCD控制器解釋

MSP430 LCD控制器解釋

CC430F613x的LCD控制器最多能控制160段。

The LCD_B controller features are:
• Display memory
• Automatic signal generation
• Configurable frame frequency
• Blinking of individual segments with separate blinking memory
• Regulated charge pump
• Contrast control by software
• Support for four types of LCDs
– Static
– 2-mux, 1/2 bias or 1/3 bias
– 3-mux, 1/2 bias or 1/3 bias
– 4-mux, 1/2 bias or 1/3 bias

把每一段對映到一個位(bit),比如LCDM1的每一個位(bit)都對應一個段。這樣有20個暫存器每個有8個位,所以能對映20*8=160段。


上圖是個靜態驅動示意圖,所謂靜態就是隻有一個公共端(COM0),這樣公共端就不需要切換了。

//******************************************************************************
//  eZ430 chronos hello world
//  Description: initializes lcd module and shows the string 'hi earth' on the
//               lcd display becuase 'hello world' is too long
//  Author: Felix Genicio
//******************************************************************************

#include  "cc430x613x.h"
#include <string.h>

void main(void)
{
	unsigned char * lcdmem;

    // Clear entire display memory
	LCDBMEMCTL |= LCDCLRBM + LCDCLRM;//清除LCD閃爍記憶體、清除LCD記憶體

	// LCD_FREQ = ACLK/16/8 = 256Hz,其中ACLK=32768Hz
	// Frame frequency = 256Hz/4 = 64Hz, LCD mux 4, LCD on
	LCDBCTL0 = (LCDDIV0 + LCDDIV1 + LCDDIV2 + LCDDIV3) | (LCDPRE0 + LCDPRE1) | LCD4MUX | LCDON;

	// LCB_BLK_FREQ = ACLK/8/4096 = 1Hz ,閃爍失能
	LCDBBLKCTL = (LCDBLKDIV0 + LCDBLKDIV1 + LCDBLKDIV2)|(LCDBLKPRE0 + LCDBLKPRE1) |  LCDBLKMOD0;

	// I/O to COM outputs
	P5SEL |= (BIT5 | BIT6 | BIT7);
	P5DIR |= (BIT5 | BIT6 | BIT7);

	// Activate LCD output
	LCDBPCTL0 = 0xFFFF;  // Select LCD segments S0-S15
	LCDBPCTL1 = 0x00FF;  // Select LCD segments S16-S22

	// LCD_B Base Address is 0A00H page 30 y in SALS554 document
	// show 'h'
	lcdmem 	= (unsigned char *)0x0A21;
	*lcdmem = (unsigned char)(*lcdmem | (BIT2+BIT1+BIT6+BIT0));
	// show 'i'
	lcdmem 	= (unsigned char *)0x0A22;
	*lcdmem = (unsigned char)(*lcdmem | (BIT2));
	// show 'E'
	lcdmem 	= (unsigned char *)0x0A2B;
	*lcdmem = (unsigned char)(*lcdmem | (BIT4+BIT5+BIT6+BIT0+BIT3));
	// show 'A'
	lcdmem 	= (unsigned char *)0x0A2A;
	*lcdmem = (unsigned char)(*lcdmem | (BIT0+BIT1+BIT2+BIT4+BIT5+BIT6));
	// show 'r'
	lcdmem 	= (unsigned char *)0x0A29;
	*lcdmem = (unsigned char)(*lcdmem | (BIT6+BIT5));
	// show 't'
	lcdmem 	= (unsigned char *)0x0A28;
	*lcdmem = (unsigned char)(*lcdmem | (BIT4+BIT5+BIT6+BIT3));
	// show 'h'
	lcdmem 	= (unsigned char *)0x0A27;
	*lcdmem = (unsigned char)(*lcdmem | (BIT4+BIT5+BIT6+BIT2));

  __no_operation();  // For debugger
}