LCD interfacing +Other Peripherals in AVR Microcontrollers Contents - - PowerPoint PPT Presentation

lcd interfacing other peripherals in avr microcontrollers
SMART_READER_LITE
LIVE PREVIEW

LCD interfacing +Other Peripherals in AVR Microcontrollers Contents - - PowerPoint PPT Presentation

Microprocessors , Lecture 11: LCD interfacing +Other Peripherals in AVR Microcontrollers Contents A brief overview over the AVR peripherals not covered by the course LCD University of Tehran 2 AVR peripherals University of Tehran 3


slide-1
SLIDE 1

LCD interfacing +Other Peripherals in AVR Microcontrollers

Microprocessors , Lecture 11:

slide-2
SLIDE 2

University of Tehran 2

Contents

  • A brief overview over the AVR peripherals not

covered by the course

  • LCD
slide-3
SLIDE 3

University of Tehran 3

AVR peripherals

slide-4
SLIDE 4

University of Tehran 4

AVR peripherals

  • PWM generation
  • Sleep mode
  • Watchdog timer
  • EPROM
  • Analog comparator
slide-5
SLIDE 5

University of Tehran 5

Sleep mode

  • To save power when the microcontroller is idle
  • Controlled by MCUCR
  • The clock is shut-down, CPU is inactive
  • Registers and SRAM keep their value
  • Wakeup on reset and interrupts
slide-6
SLIDE 6

University of Tehran 6

Sleep mode

  • SE: enables sleep mode
  • SM0 to SM2 determine the sleep type
  • After setting SE to 1, the “sleep” assembly command

should be executed – To make microcontroller enter the sleep mode – Use sleep.h functions in C to enter sleep mode – CPU exits the sleep mode by an external interrupt

slide-7
SLIDE 7

University of Tehran 7

Sleep mode

slide-8
SLIDE 8

University of Tehran 8

Two important sleep states

  • Idle state: the clock of CPU and Flash (instruction

memory) is disconnected – Other parts have their clock active

  • Power down state:

– All clocks are deactivated – Registers and PCs are stored

  • Exit by interrupts
slide-9
SLIDE 9

University of Tehran 9

Watchdog timer

  • A fault-tolerant approach
  • Resets the microcontroller if detects a crash!
  • To ensure that the microcontroller is functional

and doesn’t hang

– Start watchdog timer and set its registers to reset the micro after a time – In program disable the watchdog timer before that time – If the micro is frozen, the code that disables the watchdog is not executed and it resets the micro – Otherwise the watchdog resets the micro

slide-10
SLIDE 10

University of Tehran 10

Watchdog timer

  • Watchdog uses an independent clock (1 MHz)
  • WDTCR register controls the watchdog
slide-11
SLIDE 11

University of Tehran 11

WDTCR register

  • WDE: enable

timer

  • WPD[0-2]: the

reset time

slide-12
SLIDE 12

University of Tehran 12

Timer timeout delay

slide-13
SLIDE 13

University of Tehran 13

EEPROM

  • Kind of data memory
  • To keep permanent data not changed during time
  • Using some registers to communicate with

EEPROM

  • Two registers to send and receive data
  • A register to control read and write
slide-14
SLIDE 14

University of Tehran 14

Analog comparator

  • Compares two analog

inputs on AIN0 And AIN1 pins

  • Sets the bits of a register

based on the results to be used by the micro

slide-15
SLIDE 15

University of Tehran 15

PWM

  • Control the power of DC (Direct current) motors

While(1) { PORTB.1=1; Delay_ms(75); PORTB.1=0; Delay_ms(25); }

slide-16
SLIDE 16

University of Tehran 16

LCD

slide-17
SLIDE 17

University of Tehran 17

LCD interfacing

  • A device that Displays characters
  • Many variations
  • We study a very common 14-pin LCD
slide-18
SLIDE 18

University of Tehran 18

LCD to AVR connection

slide-19
SLIDE 19

University of Tehran 19

LCD pins

  • Lcd has two

important registers:

  • Data register:

saves the data to be shown

  • Instruction

register: commands received to do something

– e.g. clear display

slide-20
SLIDE 20

University of Tehran 20

LCD commands

  • Example: initialize

lcd for 8 bit and 5x7

  • Commands 38, 0E,

and 01 should be sent

  • To send a

command:

  • RS and w/r set to 0
  • Send appropriate

command on data pins

slide-21
SLIDE 21

University of Tehran 21

Character addresses

slide-22
SLIDE 22

University of Tehran 22

LCD 4-bit

  • Can work with 4-bit data to save pins
slide-23
SLIDE 23

University of Tehran 23

LCD commands

slide-24
SLIDE 24

University of Tehran 24

slide-25
SLIDE 25

University of Tehran 25

slide-26
SLIDE 26

University of Tehran 26

slide-27
SLIDE 27

University of Tehran 27

slide-28
SLIDE 28

University of Tehran 28