Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**************************************************//
- // Program: USART_RX_2.C //
- // Author: Austin Schaller //
- // Date: February 18st, 2011 //
- // Description: Utilizes PIC UART module //
- //**************************************************//
- #include <p18f1320.h>
- #include <delays.h>
- #include <usart.h>
- #pragma config OSC=INTIO2, WDT=OFF, LVP=OFF, DEBUG=ON
- void main()
- {
- int i;
- unsigned char data;
- OSCCONbits.IRCF0=1;
- OSCCONbits.IRCF1=1;
- OSCCONbits.IRCF2=1;
- while(!OSCCONbits.IOFS);
- TRISB = 0x02; // RB1 = USART Module I/O
- OpenUSART( USART_BRGH_LOW,31 & // 9600 Baud
- USART_ASYNCH_MODE &
- USART_CONT_RX
- );
- while(1)
- {
- LATB = 0x00;
- while(!PIR1bits.RCIF); // Wait for RCIF to OVF
- data = RCREG; // Copy data into variable
- PIR1bits.RCIF = 0; // Clear OVF Flag
- if(data==0x0A)
- {
- for(i=0;i<4;i++)
- {
- LATBbits.LATB0 = ~LATAbits.LATA0;
- Delay10KTCYx(25);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement