Vous êtes sur la page 1sur 20

LCD

(Chapter7)
andtheBasicTimer

BasicTimer
DrivenbyACLK.
BTCNT2can
BTCNT2
generateinterrupts
(asslowas1Hz:
32768/256/128)
BTCNT1isusedto
generate a clock for
generateaclockfor
LCDcontroller

HowLCDworks

Toaligncrystal,voltagemustbepureAC(average=0) typically50150Hz.

ReflectiveLCD

OneCommon(Backplane)Electrode
8Segment(SEG0SEG7)
electrodesarerequired(7
fornumeral,onefor
d i l i t)
decimalpoint).
SEG0andSEG1areoutof
phase (SEG27
phase(SEG2
7notshown).
not shown)
(SEG0alsoinphasewithSEG2,3,5
and7)

COM0SEG0islargeAC
COM0
SEG0 i l
AC
signal,sosegmentis
displayed.
COM0SEG1issmall(zero)
ACsignal,sosegmentis
*not*displayed.
8Segment+1COMis9
totalelectrodes.

TwoCommon(Backplane)Electrode
Multiplexingreducestotalnumberofelectrodes(4Seg +2COM=6electrodes)
COM0andCOM1aremorecomplex
SEG0andSEG1aremorecomplex
COM0SEG0islargeACsignal,so
COM0
SEG0 is large AC signal so
segmentisdisplayed.
COM0SEG1issmall(butnonzero)
COM0
SEG1 i
ll (b t
)
ACsignal(belowsomethreshold
value),sosegmentis*not*displayed.
OffsegmentshavesmallACvoltages,
Onsegmentshavelargevoltages
Totalnumberofsegmentsis:
(#SEG)* (#COM)

ThreeCommon(Backplane)Electrode
Andsoon

butalwaysthetotalnumberof
segmentsis:(#SEG)* (#COM)

LCD_AModule

DirectlydrivesLCDdisplaysby
creatingtheacsegmentand
commonvoltagesignals
automatically.
automatically
Featuresinclude:

Displaymemory
Automaticsignalgeneration
Configurableframefrequency
Blinkingcapability
Regulatedchargepump
Contrast control by software
Contrastcontrolbysoftware
Supportfor4typesofLCDs:

Static
2mux,1/2biasor1/3bias
3 mux 1/2 bias or 1/3 bias
3mux,1/2biasor1/3bias
4mux,1/2biasor1/3bias

Outputs
40SEG(SelectedasLCDpinsingroups)
(COM1 2 3 multiplexed with P5)
4 COM (COM1,2,3
Up to 160 segments

Voltagegeneration
(
(SeeUsersManualfordetails)

lf d
l)

Display Controller
DisplayController
Displaymemoryhas20
p y
y
bytes=160bits.
Onebitforeachdisplayable
segmentt
Thekeytousingitis
understandingthemapping
g
pp g
betweenbitsandsegments
Controllertakescareofall
voltagegeneration
l
i

ExperimentersboardLCD
22SEG*4COM=88
segments
EachSEGlinegoesto4
segments
Oneofthefourischosen
(serially)bytheCOMlines

More
Detail

S0
S1
S7

Fromasoftwareperspective,wedontcareabout
SEGsandCOMs,justthebitsintheLCDmemory.
The LCD controller takes care of details
TheLCDcontrollertakescareofdetails.

S7
S1

S0

Youdthinkthemappingsareasshown
butyoudbewrong!

Offfsetaddreessby2byttes

Correct
Mapping
pp g

S0
S1

S0SBLCDA4=S4MSP430=mem 0x93,LSBs

S7

S7SBLCDA4=S11MSP430=mem 0x96,MSBs

S1SBLCDA4=S5MSP430=mem 0x93,MSBs

S0
S1

S7

S7
S1

S0

Letslookatdigit4(S6,7SBLCDA4 =S10,11MSP430 =mem 0x96)

Digit4
g
// LCD Segments
#define LCD_A
#define LCD_B
#define LCD_C
#define LCD_D
#define LCD_E
#define LCD_F
#define LCD_G

0x01
0x02
0x04
0x08
0x40
0x10
0x20

Memory

Bit7

Bit0

096h

DP4

// LCD Segment Mapping


const UInt8 LCD_Char_Map[] =
{
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F,
LCD_B+LCD_C,
LCD A LCD B LCD D LCD E LCD G
LCD_A+LCD_B+LCD_D+LCD_E+LCD_G,
LCD_A+LCD_B+LCD_C+LCD_D+LCD_G,
LCD_B+LCD_C+LCD_F+LCD_G,
LCD_A+LCD_C+LCD_D+LCD_F+LCD_G,
LCD_A+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G,
,
LCD_A+LCD_B+LCD_C,
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G,
LCD_A+LCD_B+LCD_C+LCD_F+LCD_G,
};

//
//
//
//
//
//
//
//
//
//

'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'

// LCD Constants
#define LCD_MEM_OFFSET

Alldigits
2

// Offset from LCDMEM[0]

void dispChar(UInt8 pos, UInt8 index) {


// Display character on LCD
LCDMEM[pos + LCD_MEM_OFFSET] &= 0x80;
// Clear segments (but not 8th bit)
LCDMEM[pos + LCD_MEM_OFFSET] |= LCD_Char_Map[index]; // Set Segments
}

Maincodesetup
void main(void) {
//*******Code not shown************//
// Set ticker to 32768/(256*128) = 1 Hz, Enable BT interrupt
BTCTL = BT_fCLK2_DIV128 | BT_fCLK2_ACLK_DIV256;
IE2 |=
| BTIE;
P2DIR |= BIT2;// Bit for LED
initLCD_A();// Initialize LCD
while(1) {
//*******Code not shown************//
}
}
// Basic Timer Interrupt Service Routine
#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer_ISR(void) {
_bic_SR_register_on_exit(LPM3_bits);
}

Maincodewhile(1)
while
hil (1) {
liveTime = BTCNT2;

// Value of BTCNT2 measures time since interrupt.

_BIS_SR(LPM3_bits + GIE);
P2OUT = BIT2;

// LPM3, enable interrupts


// Turn on P2.2 (LED)

if (++sec1>9) {
sec1=0;
if (++sec10>5) {
sec10=0;
if (++min>10) min=0;
}
}
dispChar (1,sec1);
dispChar (2,sec10);
dispChar (3,min);

// Increment seconds and check for rollover


//
into 10's of seconds. If so, set sec1=0 and...
// Increment seconds and check for rollover
//
into minutes.
If so, set sec10=0 and...
// Increment minutes and check for rollover.

// Display seconds
// Display 10's of seconds
// Display minutes

LCDMEM[2 + LCD_MEM_OFFSET] ^= COLON3;


P2OUT &= ~BIT2;
}

// Toggle colon.

// Turn off P2.2 (LED)

LCDRegisters

EnablingSegments

Segmentsareenabled4
at a time
atatime

References

Verycompleteexamplecodeat:http://focus.ti.com/docs/toolsw/folders/print/mspexp430fg4618.html
link labeled: MSP430FG4618/F2013
linklabeled:
MSP430FG4618/F2013Experimenter
ExperimenterssBoardSoftware(Rev.A)
Board Software (Rev A)((http://www.ti.com/litv/zip/slac129a
http://www ti com/litv/zip/slac129a)
ThiscodeusessomeCsyntaxthatwehaventcovered.Feelfreetoaskmeifitisunclear.

Also

LCD Fundamentals http://ww1 microchip com/downloads/en/AppNotes/00658a pdf


LCDFundamentalshttp://ww1.microchip.com/downloads/en/AppNotes/00658a.pdf

MSP430x4xxFamilyUsersGuidehttp://focus.ti.com/lit/ug/slau056j/slau056j.pdf

MSP430FG4618/F2013ExperimentersBoardUsersGuidehttp://focus.ti.com/lit/ug/slau213a/slau213a.pdf

SBCLDA4Specsheethttp://www.softbaugh.com/downloads/SBLCDA4_Specification.pdf

Vous aimerez peut-être aussi