Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XTAL_FREQ 8000000
- #include <xc.h>
- #include "_LCD_H.h"
- #pragma config OSC = IRCIO, WDTEN = OFF
- #pragma config MCLRE = ON // MCLR Pin Enable bit (Enabled) turn off when on the robot
- char getCharSerial(void);
- void sendCharSerial(char charToSend);
- void Serial2String(char *string);
- volatile char string_b[16];
- void main(void) {
- int i;
- TRISC = 0b11000000; //set data direction registers
- //both need to be 1 even though RC6
- //is an output, check the datasheet!
- TRISB = 0b00000000;
- PORTB = 0;
- OSCCON = 0b11110010; //internal oscillator, 8MHz
- while (!OSCCONbits.IOFS);
- SPBRG = 204; //set baud rate to 9600
- SPBRGH = 0;
- BAUDCONbits.BRG16 = 1; //set baud rate scaling to 16 bit mode
- TXSTAbits.BRGH = 1; //high baud rate select bit
- RCSTAbits.SPEN = 1; //enable serial port, other settings default
- RCSTAbits.CREN = 1; //continous receive mode
- LCD_Init();
- while (1) {
- Serial2String(string_b);
- LCD_String(string_b);
- }
- }
- char getCharSerial(void) {
- while (!PIR1bits.RCIF);
- return RCREG;
- }
- void Serial2String(char *string) {
- do {
- *string++ = getCharSerial();
- } while(*string != '\0');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement