You are on page 1of 2

#include <p18f26k22.h> #include <delays.h> #include <usart.

h>

#pragma config FOSC = INTIO67 // Se configura para que el microcontrolador fu nciones con el Oscilador interno #pragma config PLLCFG = ON // 4X PLL Enable (Oscillator used directly) void ISRRecepcion(void); volatile char Data, Kbhit; #pragma code Interrupcion = 0x0008 void VectorInterrupcion(void){ _asm goto ISRRecepcion _endasm } #pragma code #pragma interrupt ISRRecepcion void ISRRecepcion(void) { if(PIR1bits.RC1IF == 1) { Data= getc1USART(); Kbhit=1; PIR1bits.RC1IF=0; } } void main (void) { OSCCONbits.IRCF = 0b110; TRISCbits.TRISC0 = 0; //TRISCbits.TRISC6=0; //TRISCbits.TRISC7=1; // Se configura el puerto C0 como salida // async. transmit // async. receive

Open1USART(USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EI GHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 208); //baud1USART(BAUD_IDLE_TX_PIN_STATE_HIGH & BAUD_IDLE_RX_PIN_STATE_HIGH & BAU D_AUTO_OFF & BAUD_WAKEUP_OFF & BAUD_16_BIT_RATE & USART_RX_INT_OFF); //baud1USART(BAUD_IDLE_TX_PIN_STATE_HIGH & BAUD_IDLE_RX_PIN_STATE_HIGH & BAU D_AUTO_OFF & BAUD_WAKEUP_OFF & BAUD_16_BIT_RATE & USART_RX_INT_ON); Kbhit = 0; RCONbits.IPEN = 0; //enable interrupt priority INTCONbits.PEIE = 1; //enable peripheral INTCONbits.GIE = 1; //enable all global interrupts putrs1USART("Prueba Comunicacion Serial \r"); while (1) { while(Kbhit==0){};

puts1USART(Data). } } .Kbhit=0.