Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma config FOSC = XTPLL_XT // Oscillator Selection bits (XT oscillator (XT))
- #pragma config PWRT = ON // Power-up Timer Enable bit (PWRT enabled)
- #pragma config BOR = OFF // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)
- #pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
- #pragma config PBADEN = OFF // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
- #pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
- #pragma config LVP = OFF // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
- #include <xc.h>
- #include "LCD.h"
- #include "ADC.h"
- #define _XTAL_FREQ 48000000UL
- int resulton = 0;
- int digdmi = 0;
- int digmil = 0;
- int digcen = 0;
- int digdec = 0;
- int diguni = 0;
- int temporal = 0;
- int temporal2 = 0;
- int temporal3 = 0;
- void DIGITOS(void){
- digdmi = resulton / 10000;
- temporal3 = resulton - (digdmi * 10000);
- digmil = temporal3 / 1000;
- temporal = temporal3 - (digmil * 1000);
- digcen = temporal / 100;
- temporal2 = temporal - (digcen * 100);
- digdec = temporal2 / 10;
- diguni = temporal2 - (digdec * 10);
- }
- void main(void) {
- ADC_CONFIG(0);
- TRISCbits.RC2 = 0;
- LATCbits.LC2 = 1;
- __delay_ms(500);
- TRISD = 0x00; //LCD
- LCD_CONFIG(); //inicio LCD
- __delay_ms(15);
- CURSOR_ONOFF(OFF);
- while(1){
- resulton = ADC_CONVERTIR();
- CURSOR_HOME();
- ESCRIBE_MENSAJE("Canalon ADCMON",14);
- POS_CURSOR(2,0);
- DIGITOS();
- ENVIA_CHAR(digdmi+0x30);
- ENVIA_CHAR(digmil+0x30);
- ENVIA_CHAR(digcen+0x30);
- ENVIA_CHAR(digdec+0x30);
- ENVIA_CHAR(diguni+0x30);
- __delay_ms(5);
- // __delay_ms(1000);
- // POS_CURSOR(2,0);
- // ESCRIBE_MENSAJE("UPC 2019-1",10);
- // __delay_ms(1000);
- // BORRAR_LCD();
- // __delay_ms(1000);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement