Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. int over = 0;
  2. int activat = 0;
  3. int primer = 0;
  4.  
  5. void interrupt timer(void){
  6. if(T0IF){
  7. ++over;
  8. }
  9. }
  10. void inicialitzar(){
  11. ADCON0 = 0b00000111;
  12. ADCON1 = 0b00001101;
  13. ADCON2 = 0b00100100;
  14. TRISA = 0xFF;
  15. TRISB = 0x00;
  16. over = 0;
  17. activat = 1;
  18. T0PS2 = 1;
  19. T0CON = 0;
  20. T0CS =0;
  21. PSA = 0;
  22. T0PS2 = 1;
  23. T0PS1 = 0;
  24. T0PS0 = 1;
  25. TMR0 = 0;
  26. TMR0IF = 0;
  27. TMR0IE = 1;
  28. GIE = 1;
  29. TMR0ON = 1;
  30. }
  31. void main(void)
  32. {
  33. activat = 0;
  34. inicialitzar();
  35. GLCDinit();
  36. int total = 0;
  37. while (1){
  38. if(GODONE == 0) {
  39. GODONE = 1;
  40. if(ADRESH > 100){
  41. if( activat == 0){
  42. if(primer != 0){
  43. int resultat = TMR0 + over*65536;
  44. clearGLCD(0,7,0,127);
  45. writeNum (4, 7, resultat);
  46. primer = 1;
  47. }
  48. TMR0 = 0;
  49. activat = 1;
  50. }
  51. }
  52. else activat = 0;
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement