Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. /*
  2. * Part1.c
  3. *
  4. * Created: 2018-01-22 15:07:33
  5. * Author : andnym-6
  6. */
  7.  
  8. #include <avr/io.h>
  9.  
  10. /*#define CLKPR 0x61
  11. #define LCDDR(X) 0xEC+(X)
  12. #define LCDCCR 0xE7
  13. #define LCDCRB 0xE5
  14. #define LCDCRA 0xE4
  15. #define LCDFRR 0xE6*/
  16. #define NUM0 {0x1, 0x5, 0x5, 0x1}
  17. #define NUM1 {0x0, 0x1, 0x1, 0x0}
  18. #define NUM2 {0x1, 0x1, 0xE, 0x1}
  19. #define NUM3 {0x1, 0x1, 0xB, 0x1}
  20. #define NUM4 {0x0, 0x5, 0xB, 0x0}
  21. #define NUM5 {0x1, 0x8, 0xB, 0x1}
  22. #define NUM6 {0x1, 0x8, 0xF, 0x1}
  23. #define NUM7 {0x1, 0x5, 0x1, 0x0}
  24. #define NUM8 {0x1, 0x5, 0xF, 0x1}
  25. #define NUM9 {0x1, 0x5, 0xB, 0x0}
  26.  
  27.  
  28.  
  29. int writeChar(char ch, int pos)
  30. {
  31. if(pos < 0 || pos > 5){
  32. return -1;
  33. }
  34. ch -= 48;
  35. switch(ch){
  36. case 0:
  37. LCDDR0 = num0[0];
  38. LCDDR5 = num1[1];
  39. LCDDR10 = num2[2];
  40. LCDDR15 = num3[3];
  41. ;
  42.  
  43. case 1:
  44. LCDDR0 = num7[0];
  45. LCDDR5 = num7[1];
  46. LCDDR10 = num7[2];
  47. LCDDR15 = num7[3];
  48. ;
  49.  
  50. case 2:
  51. LCDDR0 = num7[0];
  52. LCDDR5 = num7[1];
  53. LCDDR10 = num7[2];
  54. LCDDR15 = num7[3];
  55. ;
  56.  
  57. case 3:
  58. LCDDR0 = num7[0];
  59. LCDDR5 = num7[1];
  60. LCDDR10 = num7[2];
  61. LCDDR15 = num7[3];
  62. ;
  63.  
  64. case 4:
  65. LCDDR0 = num7[0];
  66. LCDDR5 = num7[1];
  67. LCDDR10 = num7[2];
  68. LCDDR15 = num7[3];
  69. ;
  70.  
  71. case 5:
  72. LCDDR0 = num7[0];
  73. LCDDR5 = num7[1];
  74. LCDDR10 = num7[2];
  75. LCDDR15 = num7[3];
  76. ;
  77.  
  78. case 6:
  79. ;
  80.  
  81. case 7:
  82. ;
  83.  
  84. case 8:
  85. ;
  86.  
  87. case 9:
  88. ;
  89. default:
  90. return -1;
  91. }
  92. return 0;
  93. }
  94.  
  95.  
  96. int main(void)
  97. {
  98. //volatile char *clkreg = (char)CLKPR;
  99. CLKPR = 0x80;
  100. CLKPR = 0x00;
  101. //volatile char *lcdccr_ptr = LCDCCR;
  102. LCDCCR = 0x0F;
  103. //volatile char *lcdcrb_ptr = LCDCRB;
  104. LCDCRB = 0xB7;
  105. //volatile char *lcdcra_ptr = LCDCRA;
  106. LCDCRA = 0xC0;
  107. //volatile char *lcdfrr_ptr = LCDFRR;
  108. LCDFRR = 0x07;
  109.  
  110. int num0[4] = NUM0;
  111. int num1[4] = NUM1;
  112. int num2[4] = NUM2;
  113. int num3[4] = NUM3;
  114. int num4[4] = NUM4;
  115. int num5[4] = NUM5;
  116. int num6[4] = NUM6;
  117. int num7[4] = NUM7;
  118. int num8[4] = NUM8;
  119. int num9[4] = NUM9;
  120.  
  121. //volatile char *lcddr = &LCDDR0;
  122. //for(int i = 0; i < 19; i++)
  123. //{
  124. // lcddr[i] = 0xFF;
  125. //}
  126. while (1)
  127. {
  128. LCDDR0 = num7[0];
  129. LCDDR5 = num7[1];
  130. LCDDR10 = num7[2];
  131. LCDDR15 = num7[3];
  132.  
  133. }
  134. return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement