Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int over = 0;
- int activat = 0;
- int primer = 0;
- void interrupt timer(void){
- if(T0IF){
- ++over;
- }
- }
- void inicialitzar(){
- ADCON0 = 0b00000111;
- ADCON1 = 0b00001101;
- ADCON2 = 0b00100100;
- TRISA = 0xFF;
- TRISB = 0x00;
- over = 0;
- activat = 1;
- T0PS2 = 1;
- T0CON = 0;
- T0CS =0;
- PSA = 0;
- T0PS2 = 1;
- T0PS1 = 0;
- T0PS0 = 1;
- TMR0 = 0;
- TMR0IF = 0;
- TMR0IE = 1;
- GIE = 1;
- TMR0ON = 1;
- }
- void main(void)
- {
- activat = 0;
- inicialitzar();
- GLCDinit();
- int total = 0;
- while (1){
- if(GODONE == 0) {
- GODONE = 1;
- if(ADRESH > 100){
- if( activat == 0){
- if(primer != 0){
- int resultat = TMR0 + over*65536;
- clearGLCD(0,7,0,127);
- writeNum (4, 7, resultat);
- primer = 1;
- }
- TMR0 = 0;
- activat = 1;
- }
- }
- else activat = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement