Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* File name: Transmit the character “U” through the asynchronous TX pin of USART
- Version: 1.0
- Author: PDA
- Company: CU
- Date: 2013
- Program function: The following example uses PORT C for an asynchronous transmission
- The ASCII character “U” is continuously sent through RC6 TX pin of the PIC18 */
- #pragma config OSC = HS //set osc mode to HS high speed clock
- #pragma config WDT = OFF // set watchdog timer off
- #pragma config LVP = OFF // Low Voltage Programming Off
- #pragma config DEBUG = OFF // Compile without extra Debug compile Code
- // Include Files
- #include <p18cxxx.h> // Device used is the PICF4520
- #include <delays.h> // Include delays headers
- void main (void)
- {
- TXSTA = 0x22; //Select high baud rate, 8 bit
- SPBRG = 64; // 19200 bps, 20MHz clock
- TXSTAbits.TXEN = 1; //Transmit enable
- RCSTAbits.SPEN = 1; // Enable serial port
- while (PIR1bits.TXIF == 0) {;} // wait until Peripheral Interrupt Flag Register is free
- TXREG = 'U';
- Delay10KTCYx(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement