scorrpeio
Full Member level 5
hi...
I am working on UART for PIC18F4520.
All I need is to send the message from pic to hyperterminal of computer.
But it is not working :sad:
Please let me know what is going wrong in it
This is the code I wrote...
void EnableUART ( void )
{
RCSTAbits.SPEN = 1;
TRISCbits.TRISC6 = 0;
PORTCbits.RC6 = 0;
BAUDCON = 0x58;
SPBRG = 0x19; //BR = 9600 for 4MHz crystal osc
INTCONbits.GIE = 0; //Disable interrupts
TXSTAbits.TXEN = 0;
TXSTAbits.SYNC = 0;
TXSTAbits.BRGH = 0;
TXSTAbits.TX9 = 0;
}
void DisableUART ( void )
{
TXSTAbits.TX9 = 0;
}
void SendMessage ( char *Msg )
{
EnableUART();
TXSTAbits.TX9 = 1;
PutCh(*Msg);
DisableUART();
}
void PutCh ( char *Msg )
{
TXREG = 'A';
while( !PIR1bits.TXIF );
do {
// TXREG = *Msg;
// *(Msg++);
}while( *Msg != 0 );
}
I am working on UART for PIC18F4520.
All I need is to send the message from pic to hyperterminal of computer.
But it is not working :sad:
Please let me know what is going wrong in it
This is the code I wrote...
void EnableUART ( void )
{
RCSTAbits.SPEN = 1;
TRISCbits.TRISC6 = 0;
PORTCbits.RC6 = 0;
BAUDCON = 0x58;
SPBRG = 0x19; //BR = 9600 for 4MHz crystal osc
INTCONbits.GIE = 0; //Disable interrupts
TXSTAbits.TXEN = 0;
TXSTAbits.SYNC = 0;
TXSTAbits.BRGH = 0;
TXSTAbits.TX9 = 0;
}
void DisableUART ( void )
{
TXSTAbits.TX9 = 0;
}
void SendMessage ( char *Msg )
{
EnableUART();
TXSTAbits.TX9 = 1;
PutCh(*Msg);
DisableUART();
}
void PutCh ( char *Msg )
{
TXREG = 'A';
while( !PIR1bits.TXIF );
do {
// TXREG = *Msg;
// *(Msg++);
}while( *Msg != 0 );
}