Advertisement
Guest User

LAB2 termin1

a guest
Nov 27th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 1.45 KB | None | 0 0
  1. sbit LCD_RS at RA4_bit;
  2. sbit LCD_EN at RA5_bit;
  3. sbit LCD_D4 at RA0_bit;
  4. sbit LCD_D5 at RA1_bit;
  5. sbit LCD_D6 at RA2_bit;
  6. sbit LCD_D7 at RA3_bit;
  7. sbit LCD_RS_Direction at TRISA4_bit;
  8. sbit LCD_EN_Direction at TRISA5_bit;
  9. sbit LCD_D4_Direction at TRISA0_bit;
  10. sbit LCD_D5_Direction at TRISA1_bit;
  11. sbit LCD_D6_Direction at TRISA2_bit;
  12. sbit LCD_D7_Direction at TRISA3_bit;
  13.  
  14. int regime = 1;
  15. int cnt=0;
  16. int printName=1;
  17. int needToPrint=1;
  18. char *name = "DARIO";
  19. char *index = "151034";
  20.  
  21. void interrupt(){
  22.  
  23. if(INTF_bit==1 && PORTB.b0==0){
  24.   regime++;
  25.   needToPrint=1;
  26.   if(regime==4){
  27.     regime=1;
  28.   }
  29.   INTF_bit=0;
  30. }else if(TMR0IF_bit){
  31.   cnt++;
  32.   TMR0IF_bit=0;
  33.   TMR0=0;
  34. }
  35.  
  36. }
  37.  
  38. void main() {
  39.  
  40. ANSEL=0;
  41. ANSELH=0;
  42. INTCON=0b10110000;
  43.  
  44. TMR0=0;
  45. OPTION_REG=0x83;
  46.  
  47. PORTC=0x00;
  48. TRISC=0x00;
  49. PORTB=0x00;
  50. TRISB=0x01;
  51.  
  52. LCD_INIT();
  53. LCD_CMD(_LCD_CURSOR_OFF);
  54. LCD_CMD(_LCD_CLEAR);
  55.  
  56. while(1) {
  57.  
  58.   if(regime == 1){
  59.  
  60.     if(needToPrint==1){
  61.       LCD_CMD(_LCD_CLEAR);
  62.       PORTC=0x01;
  63.       LCD_OUT(1,6,name);
  64.       LCD_OUT(2,1,index);
  65.       needToPrint=0;
  66.     }
  67.    
  68.   } else if (regime == 2){
  69.    
  70.     if(cnt>=12){
  71.       LCD_CMD(_LCD_CLEAR);
  72.       if(printName==1){
  73.         printName=0;
  74.         LCD_OUT(1,1,name);
  75.       }else{
  76.         printName=1;
  77.         LCD_OUT(2,1,index);
  78.       }
  79.       cnt=0;
  80.     }
  81.     PORTC=0x02;
  82.  
  83.   } else {
  84.  
  85.     LCD_CMD(_LCD_CLEAR);
  86.     PORTC=0x03;
  87.     needToPrint=1;
  88.  
  89.   }
  90.  
  91. }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement