16F877 & USART & Interrupt & Recieve Problem

Thread Starter

LuxFerre

Joined Jul 5, 2007
5
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):eek:. 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)
{

}
}
 

Thread Starter

LuxFerre

Joined Jul 5, 2007
5
yes im using MAX 232 equivalent HIN232..


maybe it helps;
im measuring 0 Volts on Pic's Receieve pin..
ive changed ihn232 with another but it stands like this.
im using 5 1uF caps..
ive tried both shorted RTS CTS - DTR DSR pins and not shorted.. only 2 pins connected ( RD TD )
it didnt help..
im using hyperterminal in handshaking none mode..
im thinking of a problem in software but it works in proteus..
maybe hardware
aarghh.. ive not much time.
(a circuit schematic will be nice but my draws are a mess..)
 

Thread Starter

LuxFerre

Joined Jul 5, 2007
5
Problem solved..
The Problem is LCD panel.. I forgot it connected as i manipulate PORTB as all high..
This confused the pic i think...
thanx for your help..
 
Top