Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <p18cxxx.h>
- #include <stdio.h>
- #include <usart.h>
- #include <delays.h>
- #pragma config OSC = INTIO67
- #pragma config FCMEN = OFF
- #pragma config IESO = OFF
- #pragma config PWRT = ON
- #pragma config BOREN = OFF
- #pragma config WDT = OFF
- #pragma config MCLRE = OFF
- #pragma config PBADEN = OFF
- #pragma config LVP = OFF
- //This will delay 1 second at 8 MHz, if you decide to change the clock frequency, you need to recalculate this function to time it right again.
- void delay1s() {
- Delay10KTCYx(200);
- }
- void main() {
- OSCCON = 0b01110010; //8 MHz, set this to whatever frequency you want
- TRISC = 0x00; //All output, but if you want the PIC to receive data, RC7 should be input.
- //Set up the UART, all this info is in the C18 library guide pdf file.
- //See this site as well: http://electronicfr.com/index.php/Microcontrolers-programing/Memo-and-code-exemples-for-C18-programing.html
- OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 12);
- while(1) {
- printf("Hello, printf!\n");
- delay1s();
- }
- CloseUSART();
- while(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement