Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART RX not working whereas TX is working (PIC16F)

Status
Not open for further replies.

Soumyajit

Junior Member level 3
Joined
Feb 8, 2012
Messages
29
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,283
Location
Bangalore, India
Activity points
1,448
Hello All,
I have configured the UART on PIC16F690 for data reception as well as transmission, the tx is working fine and data is perfectly received on the computer terminal through COM port. But when I send data to the MCU from the computer, the data isn't coming up. I confirmed using an oscilloscope that the data is actually coming to the MCU RX pin but the RCIF flag is NOT set in the program while the MCU is running. I am using 8 Mhz internal oscillator of the MCU. I am configuring the peripheral this way as shown below:

void init_peripherals(void)
{

TRISB5 = 1; // RX Pin
TRISB7 = 0; // TX Pin


SPBRG = 1666 % 256; // 1200 BPS
SPBRGH = 1666 / 256;

//BAUDCTL
ABDOVF = 0;//Auto Baud overflow Status
RCIDL = 0;//Receiver Idle status bit
SCKP = 0;//Transmitt inverted/non-inverted data
BRG16 = 1;//16-bit baud rate generator enable
WUE = 0;//Wake Up enable
ABDEN = 0;//Auto Baud Detect Enable

//TXSTA
CSRC = 0;//clock source select in synchronous mode
TX9 = 0;//9bit or 8bit transmission selection
TXEN = 1;//transmission enable
SYNC = 0;//synchronous or asynchronous mode
SENDB = 0;//send break
BRGH = 1;//high baud rate selection
TRMT = 1;//transmitt shift register status
TX9D = 0;//ninth bit of tx data

//RCSTA
RX9 = 0;//9th bit receive enable
SREN = 0;//single receive enable in synchronous mode
//CREN = 1;//continuous receive enable
ADDEN = 0;//address detect enable
FERR = 0;//framing error status
OERR = 0;//overrun error status
RX9D = 0;//rth bit of receive data
SPEN = 1;//UART enable

RCIE = 1;
PEIE = 1;
GIE = 1;

CREN = 1;//continuous receive enable

T1CON = 0x001; // Enable Timer 1
TMR1IE = 1; // Enable Timer1 Interrupt

}

Can anyone suggest me what is going wrong?
 

this is the UART initialisation I use on a Microchip PICDEM Mechatronics board using a PIC16F917 - it may help
Code:
void UARTInit(void)
{
    OSCCON=0x71;				// Fosc use internal oscillator 8MHz
	TXSTA=0;					// set up transmitter
	TXEN=1;						// Asychronous, 8 bit, BRGH=1
	BRGH=1;
	TRMT=1;
    TRISC6=1;

	RCSTA=0;					// set up receiver
	SPEN=1;						// Asychronous, 8 bit, continuous receive, serial enable
	CREN=1;    
	TRISC7=0;

// calculate Baud Rate = FOSC/(16 (X + 1))
//#define BaudRate 	51 	//SPBRG value for 9600 Baud when Fosc=8MHz and BRGH=1
#define BaudRate    8 	//SPBRG value for 57600 Baud when Fosc=8MHz and BRGH=1
	SPBRG=BaudRate;  			// setup baud rate
}
 

hello,


Show us all the code
How do you treat UART RX via interrupt ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top