Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. // LCD module connections
  2. sbit LCD_RS at P2_4_bit;  //+
  3. sbit LCD_EN at P2_6_bit;   //+
  4. sbit LCD_RW at P2_5_bit;   //+
  5. sbit LCD_CS1B at P2_2_bit; //+
  6. sbit LCD_CS2B at P2_3_bit; //+
  7. sbit LCD_RST at P2_7_bit; //0
  8.  
  9. sbit LCD_D0 at P0_0_bit;
  10. sbit LCD_D1 at P0_1_bit;
  11. sbit LCD_D2 at P0_2_bit;
  12. sbit LCD_D3 at P0_3_bit;
  13. sbit LCD_D4 at P0_4_bit;
  14. sbit LCD_D5 at P0_5_bit;
  15. sbit LCD_D6 at P0_6_bit;
  16. sbit LCD_D7 at P0_7_bit;
  17. // End LCD module connections
  18.  
  19. char txt4[] = "example";                           // Loop variable
  20.  
  21.  
  22. int wrProc(char my_data) {
  23.     LCD_EN = 0;
  24.     LCD_RW =  0;
  25.     P0 = my_data;
  26.     LCD_EN = 1;
  27.     return 1;
  28. }
  29. int wrCommand(char my_data){
  30.     LCD_RS = 0;
  31.     return wrProc(my_data);
  32. }
  33. int wrData(char my_data){
  34.     LCD_RS = 1;
  35.     return wrProc(my_data);
  36. }
  37.  
  38. int isBusy () {
  39.     if(LCD_D7 == 1)
  40.         return 1;
  41.     return 0;
  42. }
  43.  
  44.  
  45. int init() {
  46.     LCD_EN = 1;
  47.     LCD_RW =  1;
  48.     LCD_CS1B = 1;
  49.     LCD_CS2B = 1;
  50.     P0 = 255;
  51.     return 1;
  52. }
  53.  
  54. int index;
  55. char my_data = 0x1;
  56. void main(){
  57.      P0 = 255;
  58.      LCD_CS2B = 1;
  59. //  init();
  60.   while(1) {
  61. //     wrCommand(255);
  62. //     wrData(0);
  63.     LCD_CS1B=0;
  64.     wrCommand(0x3f); //display on
  65.     Delay_ms(50);
  66.     wrCommand(0x40); // set addr 0
  67.     Delay_ms(50);
  68.     wrCommand(0xb9);   //set page 0
  69.     Delay_ms(50);
  70.     wrCommand(0xc0);   //display start line 0
  71.     Delay_ms(50);
  72.  
  73.     for(index = 0; index < 64; index++){
  74.    
  75.        wrData(my_data);
  76.        my_data= my_data << 1;
  77.        Delay_ms(100);
  78.     }
  79.    
  80.     LCD_CS1B=1;
  81.  
  82.   }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement