Advertisement
Guest User

lab10

a guest
May 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.03 KB | None | 0 0
  1. #pragma config FOSC = XTPLL_XT     // Oscillator Selection bits (XT oscillator (XT))
  2. #pragma config PWRT = ON        // Power-up Timer Enable bit (PWRT enabled)
  3. #pragma config BOR = OFF        // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)
  4. #pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
  5. #pragma config PBADEN = OFF     // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
  6. #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  7. #pragma config LVP = OFF        // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
  8.  
  9. #include <xc.h>
  10. #include "LCD.h"
  11. #include "ADC.h"
  12. #define _XTAL_FREQ 48000000UL
  13.  
  14. int resulton = 0;
  15. int digdmi = 0;
  16. int digmil = 0;
  17. int digcen = 0;
  18. int digdec = 0;
  19. int diguni = 0;
  20. int temporal = 0;
  21. int temporal2 = 0;
  22. int temporal3 = 0;
  23.  
  24. void DIGITOS(void){
  25.     digdmi = resulton / 10000;
  26.     temporal3 = resulton - (digdmi * 10000);
  27.     digmil = temporal3 / 1000;
  28.     temporal = temporal3 - (digmil * 1000);
  29.     digcen = temporal / 100;
  30.     temporal2 = temporal - (digcen * 100);
  31.     digdec = temporal2 / 10;
  32.     diguni = temporal2 - (digdec * 10);        
  33. }
  34.  
  35. void main(void) {
  36.     ADC_CONFIG(0);
  37.     TRISCbits.RC2 = 0;
  38.     LATCbits.LC2 = 1;
  39.     __delay_ms(500);
  40.     TRISD = 0x00; //LCD
  41.     LCD_CONFIG(); //inicio LCD
  42.     __delay_ms(15);
  43.     CURSOR_ONOFF(OFF);
  44.     while(1){
  45.         resulton = ADC_CONVERTIR();
  46.         CURSOR_HOME();
  47.         ESCRIBE_MENSAJE("Canalon ADCMON",14);
  48.         POS_CURSOR(2,0);
  49.         DIGITOS();
  50.         ENVIA_CHAR(digdmi+0x30);
  51.         ENVIA_CHAR(digmil+0x30);
  52.         ENVIA_CHAR(digcen+0x30);
  53.         ENVIA_CHAR(digdec+0x30);
  54.         ENVIA_CHAR(diguni+0x30);
  55.             __delay_ms(5);
  56. //        __delay_ms(1000);
  57. //        POS_CURSOR(2,0);
  58. //        ESCRIBE_MENSAJE("UPC 2019-1",10);
  59. //        __delay_ms(1000);
  60. //        BORRAR_LCD();
  61. //        __delay_ms(1000);
  62.     }
  63.     return;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement