Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. /* File name: Transmit the character “U” through the asynchronous TX pin of USART
  2. Version: 1.0
  3. Author: PDA
  4. Company: CU
  5. Date: 2013
  6. Program function: The following example uses PORT C for an asynchronous transmission
  7. The ASCII character “U” is continuously sent through RC6 TX pin of the PIC18 */
  8.  
  9.  
  10. #pragma config OSC = HS //set osc mode to HS high speed clock
  11. #pragma config WDT = OFF // set watchdog timer off
  12. #pragma config LVP = OFF // Low Voltage Programming Off
  13. #pragma config DEBUG = OFF // Compile without extra Debug compile Code
  14.  
  15. // Include Files
  16. #include <p18cxxx.h> // Device used is the PICF4520
  17. #include <delays.h> // Include delays headers
  18.  
  19. void main (void)
  20. {
  21.     TXSTA = 0x22; //Select high baud rate, 8 bit
  22.     SPBRG = 64; // 19200 bps, 20MHz clock
  23.     TXSTAbits.TXEN = 1; //Transmit enable
  24.     RCSTAbits.SPEN = 1; // Enable serial port
  25.     while (PIR1bits.TXIF == 0) {;} // wait until Peripheral Interrupt Flag Register is free
  26.    
  27.     TXREG = 'U';
  28.     Delay10KTCYx(50);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement