hai all.....
i have involve in project using uart, but the problem occur during i want sending data. i.e if i want send 1010 from pic to pc the output at pc is diffrent. But if i used printf the word i.e "hello world" i send from PIC will occur correctly in pc, are my programming error or something that i don't know occur.
#include<pic.h>
#include<htc.h>
#include<stdio.h>
#define _XTAL_FREQ 20000000 //clock speed
__CONFIG(0x3F32); //16 bit setting
// start write function
#define uart_tx RC6
#define tx_tris TRISC6
#define uart_rx RC7
#define rx_tris TRISC7
void set_com(){
tx_tris = 0;
rx_tris = 1;
SPBRG = 129;
TXSTA = 0b00100100;
RCSTA = 0b10010000;
}
void write(unsigned char byte){
while(!TXIF)
continue;
TXREG = byte;
}
unsigned char read(){
while(!RCIF)
continue;
return RCREG;
}
thanks for viewing........
i have involve in project using uart, but the problem occur during i want sending data. i.e if i want send 1010 from pic to pc the output at pc is diffrent. But if i used printf the word i.e "hello world" i send from PIC will occur correctly in pc, are my programming error or something that i don't know occur.
#include<pic.h>
#include<htc.h>
#include<stdio.h>
#define _XTAL_FREQ 20000000 //clock speed
__CONFIG(0x3F32); //16 bit setting
// start write function
#define uart_tx RC6
#define tx_tris TRISC6
#define uart_rx RC7
#define rx_tris TRISC7
void set_com(){
tx_tris = 0;
rx_tris = 1;
SPBRG = 129;
TXSTA = 0b00100100;
RCSTA = 0b10010000;
}
void write(unsigned char byte){
while(!TXIF)
continue;
TXREG = byte;
}
unsigned char read(){
while(!RCIF)
continue;
return RCREG;
}
thanks for viewing........