Hello..
Im trying to make a connection between PC and PIC as you get from the topic..
In Hyperterminal; my pic can send a char. There is no problem. But when receiving any data, my pic doesnt break his silence. And this frustrates me..
As i search on net (and go into my electronic knowledge), i find that i should make common ground (pin 5). But when i try this; my pic doesnt send any char. (and nor recieves any data / char)When i leave this pin (5) float, it can send char. (dont say my pic is a little ... you get it)(and it cant receive)
. I think maybe i have problems in software. But it works well in Proteus / ISIS.
Any idea will be great help..
Sincerely..
P.S. my code:
#include <htc.h>
#include <delay.c>
void hatasil(void){
unsigned char zed;
if (OERR) {
TXEN=0;
TXEN=1;
CREN=0;
CREN=1;
}
if (FERR) {
zed=RCREG;
TXEN=0;
}
}
char verial(void) {
hatasil();
return RCREG;
}
void interrupt kesme(void){
if(RCIF) {
unsigned char yak;
RB5=0;
DelayMs(250);
DelayMs(250);
DelayMs(250);
DelayMs(250);
RB5=1;
yak=verial();
//yak++;
RCIF=0;
DelayMs(50);
TXREG=yak;
}
}
main(void){
unsigned char alik;
OPTION=0xFF;
INTCON=0b11000000; //çevrebirimlerinin kesme modunun aktifleştirilmesi
PIE1=0b00100000; //USART alış kesmesi aktifleştirilmesi
//Kesme hazırlama prosedürü
TRISC=254;
//USART hazırlama prosedürü
SPBRG=129; //20 MHz. kristal için 9.6kbaud
BRGH=1; //yüksek hız baud oranı
SYNC=0; //asenktron çalışma
TX9=0; //8 bit çalışma
RX9=0; //8 bit çalışma
SPEN=1; //seri port aktifle
RCIE=1;
CREN=1; //RX aktifle
TXEN=0; //reset TX
TXEN=1; //TX aktif yap
RCIF=0;
//PORTB hazırlanması
TRISB=0;
PORTB=0;
alik='b';
RB5=1;
while(!TXIF)
{
TXEN=0;
TXEN=1;
}
TXREG=alik;
while(1)
{
}
}
Im trying to make a connection between PC and PIC as you get from the topic..
In Hyperterminal; my pic can send a char. There is no problem. But when receiving any data, my pic doesnt break his silence. And this frustrates me..
As i search on net (and go into my electronic knowledge), i find that i should make common ground (pin 5). But when i try this; my pic doesnt send any char. (and nor recieves any data / char)When i leave this pin (5) float, it can send char. (dont say my pic is a little ... you get it)(and it cant receive)
Any idea will be great help..
Sincerely..
P.S. my code:
#include <htc.h>
#include <delay.c>
void hatasil(void){
unsigned char zed;
if (OERR) {
TXEN=0;
TXEN=1;
CREN=0;
CREN=1;
}
if (FERR) {
zed=RCREG;
TXEN=0;
}
}
char verial(void) {
hatasil();
return RCREG;
}
void interrupt kesme(void){
if(RCIF) {
unsigned char yak;
RB5=0;
DelayMs(250);
DelayMs(250);
DelayMs(250);
DelayMs(250);
RB5=1;
yak=verial();
//yak++;
RCIF=0;
DelayMs(50);
TXREG=yak;
}
}
main(void){
unsigned char alik;
OPTION=0xFF;
INTCON=0b11000000; //çevrebirimlerinin kesme modunun aktifleştirilmesi
PIE1=0b00100000; //USART alış kesmesi aktifleştirilmesi
//Kesme hazırlama prosedürü
TRISC=254;
//USART hazırlama prosedürü
SPBRG=129; //20 MHz. kristal için 9.6kbaud
BRGH=1; //yüksek hız baud oranı
SYNC=0; //asenktron çalışma
TX9=0; //8 bit çalışma
RX9=0; //8 bit çalışma
SPEN=1; //seri port aktifle
RCIE=1;
CREN=1; //RX aktifle
TXEN=0; //reset TX
TXEN=1; //TX aktif yap
RCIF=0;
//PORTB hazırlanması
TRISB=0;
PORTB=0;
alik='b';
RB5=1;
while(!TXIF)
{
TXEN=0;
TXEN=1;
}
TXREG=alik;
while(1)
{
}
}