Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 1.47 KB | None | 0 0
  1. sbit LCD_RS at RB4_bit;
  2. sbit LCD_EN at RB5_bit;
  3. sbit LCD_D4 at RB0_bit;
  4. sbit LCD_D5 at RB1_bit;
  5. sbit LCD_D6 at RB2_bit;
  6. sbit LCD_D7 at RB3_bit;
  7.  
  8. sbit LCD_RS_Direction at TRISB4_bit;
  9. sbit LCD_EN_Direction at TRISB5_bit;
  10. sbit LCD_D4_Direction at TRISB0_bit;
  11. sbit LCD_D5_Direction at TRISB1_bit;
  12. sbit LCD_D6_Direction at TRISB2_bit;
  13. sbit LCD_D7_Direction at TRISB3_bit;
  14.  
  15. int i= 0, secunda = 0,interval = 0;
  16. char sec[16];
  17.  
  18. void interrupt()
  19. {
  20.      INTCON.GIE=0;
  21.      if(INTCON.T0IF)
  22.      {
  23.         INTCON.T0IF=0;
  24.         i++;
  25.         TMR0 = 99;
  26.         if (i == 50)
  27.         {
  28.            secunda++;
  29.            i = 0;
  30.  
  31.         }
  32.  
  33.      }
  34.       INTCON.GIE=1;
  35. }
  36.  
  37. void initializare(){
  38.      CMCON0.C1INV = 0;
  39.      CMCON0.CM2=1;
  40.      CMCON0.CM1=0;
  41.      CMCON0.CM0=0;
  42.      TRISD.RD0=0;
  43.      INTCON = 0b10100000;
  44.      OPTION_REG = 0b00000101;
  45.      Lcd_Init();
  46.      Lcd_Cmd(_LCD_CURSOR_OFF);
  47. }
  48.  
  49. void main() {
  50.  
  51.  
  52.      initializare();
  53.       interval = secunda;
  54.      
  55.      while(1){  
  56.                 PORTD.RD0 = 0;
  57.                 IntToStr(secunda, sec);
  58.                  Lcd_Out(1,1,sec);
  59.  
  60.  
  61.                 if(secunda-interval==10){
  62.  
  63.  
  64.                 PORTD.RD0 = 1;
  65.                 if(CMCON0.C1OUT == 0){
  66.                 Lcd_Out(2,1,"Pot. RA0>=RA3");
  67.                 }
  68.                 else if(CMCON0.C1OUT == 1){
  69.                 Lcd_Out(2,1,"Pot. RA0<RA3");
  70.                 }
  71.                 interval = secunda;
  72.                 }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.         }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement