Advertisement
Electgpl

PIC - Funcion Millis

Oct 24th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <16f877A.h>
  2. #fuses XT,NOWDT,NOPROTECT,NOLVP,PUT,BROWNOUT,NOCPD,NOWRT
  3. #use delay (clock=4000000)
  4. #BYTE PORTB=0x06
  5. #BYTE TRISB=0x86
  6. #include "lcd.c"
  7. long millis;
  8. long tiempo;
  9. long cont;
  10. #INT_TIMER0
  11. void TIMER0_isr(){
  12.    millis=millis+1;
  13.    set_timer0(6);
  14. }
  15. void main(){
  16.    TRISB=0x00;
  17.    PORTB=0;
  18.    output_high(PIN_B0);
  19.    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
  20.    set_timer0(6);
  21.    enable_interrupts(INT_TIMER0);
  22.    enable_interrupts(GLOBAL);
  23.    lcd_init();
  24.    tiempo=millis;
  25.    while(TRUE){
  26.       if(millis-tiempo>=1000){
  27.          lcd_gotoxy(5,2);
  28.          printf(lcd_putc,"\Conv=%lu ",millis-tiempo);
  29.          lcd_gotoxy(1,1);
  30.          printf(lcd_putc,"\Cont=%lu ",cont++);    
  31.          PORTB=PORTB|0b00000001;
  32.          PORTB=PORTB|0b00000100;
  33.          tiempo=millis;
  34.       }  
  35.    }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement