Rainbow Electronics ATmega3290P_V User Manual

Page 227

Advertising
background image

227

ATmega329/3290/649/6490

2552H–AVR–11/06

Note:

1. See “About Code Examples” on page 8.

Assembly Code Example

(1)

LCD_Init:

; Use 32 kHz crystal oscillator

; 1/3 Bias and 1/3 duty, SEG21:SEG24 is used as port pins

ldi

r16, (1<<LCDCS) | (1<<LCDMUX1)| (1<<LCDPM2)

sts

LCDCRB,

r16

; Using 16 as prescaler selection and 7 as LCD Clock Divide

; gives a frame rate of 49 Hz

ldi

r16, (1<<LCDCD2) | (1<<LCDCD1)

sts

LCDFRR, r16

; Set segment drive time to 125

µs and output voltage to 3.3 V

ldi

r16, (1<<LCDDC1) | (1<<LCDCC3) | (1<<LCDCC2) | (1<<LCDCC1)

sts

LCDCCR, r16

; Enable LCD, default waveform and no interrupt enabled

ldi

r16, (1<<LCDEN)

sts

LCDCRA, r16

ret

C Code Example

(1)

Void LCD_Init(void);

{

/* Use 32 kHz crystal oscillator */

/* 1/3 Bias and 1/3 duty, SEG21:SEG24 is used as port pins */

LCDCRB = (1<<LCDCS) | (1<<LCDMUX1)| (1<<LCDPM2);

/* Using 16 as prescaler selection and 7 as LCD Clock Divide */

/* gives a frame rate of 49 Hz */

LCDFRR = (1<<LCDCD2) | (1<<LCDCD1);

/* Set segment drive time to 125

µs and output voltage to 3.3 V*/

LCDCCR = (1<<LCDDC1) | (1<<LCDCC3) | (1<<LCDCC2) | (1<<LCDCC1);

/* Enable LCD, default waveform and no interrupt enabled */

LCDCRA = (1<<LCDEN);

}

Advertising