Advertisement
Soulseller

Untitled

May 23rd, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4. #define LCDDR_RS DDRA
  5. #define LCDDR_E DDRD
  6. #define LCDDR_D DDRC
  7. #define LCDPORT_RS PORTA
  8. #define LCDPORT_E PORTD
  9. #define LCDPORT_D PORTC
  10. #define LCD_E PD6
  11. #define LCD_RS PA2
  12.  
  13.  
  14. void enable()
  15. {
  16.     LCDPORT_E |= (1<<LCD_E);
  17.     _delay_us(1);
  18.     LCDPORT_E &= ~(1<<LCD_E);
  19.     _delay_us(4000);
  20. }
  21.  
  22. void init()
  23. {
  24.     _delay_ms(15);
  25.     LCDDR_RS |= (1<<LCD_RS);
  26.     LCDDR_E |= (1<<LCD_E);
  27.     LCDDR_D = 0b11110000;
  28.  
  29.     LCDPORT_D = 0x30;
  30.     enable();
  31.     enable();
  32.     enable();
  33.  
  34.     LCDPORT_D =0x20;
  35.     enable();
  36.  
  37.     LCDPORT_D = 0x20;
  38.     enable();
  39.     LCDPORT_D = 0x80;
  40.     enable();
  41.  
  42.     LCDPORT_D = 0x00;
  43.     enable();
  44.     LCDPORT_D = 0x10;
  45.     enable();
  46.  
  47.     LCDPORT_D = 0x00;
  48.     enable();
  49.     LCDPORT_D = 0xc0;
  50.     enable();
  51.  
  52. }
  53.  
  54.  
  55.  
  56. int main()
  57. {
  58.     init();
  59.     //Zeichen A ausgeben 0x41
  60.     LCDPORT_D = 0x40;
  61.     LCDPORT_RS |= (1<<LCD_RS);
  62.     enable();
  63.     LCDPORT_D = 0x10;
  64.     LCDPORT_RS |= (1<<LCD_RS);
  65.     enable();
  66.  
  67.     PORTA =0;
  68.     PORTB =0;
  69.     PORTC =0;
  70.     PORTD =0;
  71.  
  72.     while(1)
  73.     {
  74.    
  75.  
  76.     };
  77.  
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement