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.

NEED help for UART transmission for pic18f87j11

Status
Not open for further replies.

dhaval496

Newbie level 1
Newbie level 1
Joined
Jan 30, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
i have written this code for UART transmission, but with this code i am not able to transmit so please anyone can help me on this


include "p18F87J11.h"
#include"htc.h"

void main ()
{
TRISD=0;





///////////////////////////////////////////////////////////////////////////////////////////

TRISCbits.RC7=1; //RX1 for EUASRT module 1
TRISCbits.RC6=0; //TX1 for EUASRT module 1
TXSTA1bits.SYNC=0; // asychronous mode
TXSTA1bits.BRGH=1; // high speed baud rate mode
BAUDCON1bits.BRG16=0; // 8-bit baud rate generator
SPBRG1=0x81; // baud rate =9600
RCSTA1bits.SPEN=1; // serial port enable
TXSTA1bits.TXEN=1; //transmitt enable


// SPBRGH1=0x00;
INTCONbits.GIE=1; // enable all high priority interrupt
INTCONbits.PEIE=1; // enable all unmasked pheripheral inputs

//////////////////////////////////////////////////////////////////////////////////////////////////

IPR1bits.TX1IP=1; // highest interrupt priority for transmission
PIE1bits.TX1IE=1; // interrupt enable



//////////////////////////////////////////////////////////////////////////////

// IPR1bits.RC1IP=0; // law priority for reception
// PIE1bits.RC1IE=1; // interrupt enable
// RCSTA1bits.CREN=1; // enable receiver


/////////////////////////////////////////////////////////////////////////////////////

TXREG1= 'a';

while(TXSTA1bits.TRMT==0)
// if(TXSTA1bits.TRMT==1)
//while(PIR1bits.TX1IF==0)
{
PORTD=0x00;

}
PORTD=0xff;
while(1);

//PORTD=0x55;


}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top