lcd interfacing other peripherals in avr microcontrollers
play

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


  1. Microprocessors , Lecture 11: LCD interfacing +Other Peripherals in AVR Microcontrollers

  2. Contents • A brief overview over the AVR peripherals not covered by the course • LCD University of Tehran 2

  3. AVR peripherals University of Tehran 3

  4. AVR peripherals • PWM generation • Sleep mode • Watchdog timer • EPROM • Analog comparator University of Tehran 4

  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 University of Tehran 5

  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 University of Tehran 6

  7. Sleep mode University of Tehran 7

  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 University of Tehran 8

  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 University of Tehran 9

  10. Watchdog timer • Watchdog uses an independent clock (1 MHz) • WDTCR register controls the watchdog University of Tehran 10

  11. WDTCR register • WDE: enable timer • WPD[0-2]: the reset time University of Tehran 11

  12. Timer timeout delay University of Tehran 12

  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 University of Tehran 13

  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 University of Tehran 14

  15. PWM • Control the power of DC (Direct current) motors While(1) { PORTB.1=1; Delay_ms(75); PORTB.1=0; Delay_ms(25); } University of Tehran 15

  16. LCD University of Tehran 16

  17. LCD interfacing • A device that Displays characters • Many variations • We study a very common 14-pin LCD University of Tehran 17

  18. LCD to AVR connection University of Tehran 18

  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 University of Tehran 19

  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 University of Tehran 20

  21. Character addresses University of Tehran 21

  22. LCD 4-bit • Can work with 4-bit data to save pins University of Tehran 22

  23. LCD commands University of Tehran 23

  24. University of Tehran 24

  25. University of Tehran 25

  26. University of Tehran 26

  27. University of Tehran 27

  28. University of Tehran 28

Recommend


More recommend