The pins of the Enhanced USART are multiplexed
with PORTC. In order to configure RC6/TX/CK and
RC7/RX/DT as a USART:
• bit SPEN (RCSTA<7>) must be set (= 1)
• bit TRISC<7> must be set (= 1)
• bit TRISC<6> must be set (= 1)
bit 6 TX9: 9-bit Transmit Enable bit
1 = Selects 9-bit transmission
0 = Selects 8-bit transmission
bit 5 TXEN: Transmit Enable bit
1 = Transmit enabled
0 = Transmit disabled
#define StatusMSG1 "Booting Begins"
void main()
{
// Indicator LED ON
TRISB = 0x00; // Configure PORTB-pins as outputs
PORTB = 0b00000111;
//Initialise UART port for communication with Computer
EnableUART();
//Start Sending Status message on Port 80 (UART)
SendMessage(StatusMSG1);
//Initialise the Display like LCD
InitialiseDisplay();
while(1)
{
}
}
void EnableUART ( void )
{
TRISCbits.TRISC6 = 1;
SPBRG = 25; //BR = 9600
TXSTAbits.TXEN = 0;
TXSTAbits.BRGH = 1;
RCSTAbits.SPEN = 1;
BAUDCTLbits.BRG16 = 0;
TXSTAbits.SYNC = 0;
TXSTAbits.TX9 = 0;
INTCONbits.GIE = 0; //Disable interrupts
TXSTAbits.TXEN = 0;
TXSTAbits.TXEN = 1;
}
void SendMessage ( ram char* Msg )
{
while(*Msg)
{
TXREG = *Msg;
while( !PIR1bits.TXIF );
Msg++;
}
TXREG = NEWLINE;
}
lcd_strram((const ram char*) buffer);
void lcd_strram (const ram char *str)
{
while(*str){
lcd_data(*str++);
}
}
#define StatusMSG1 "Booting Started"
const char msg[]= StatusMSG1;
// Indicator LED ON
TRISB = 0x00; // Configure PORTB-pins as outputs
PORTB = 0b00000111;
//Initialise UART port for communication with Computer
EnableUART();
//Start Sending Status message on Port 80 (UART)
//SendMessage(StatusMSG1);
SendMessage(msg);
//Initialise the Display like LCD
InitialiseDisplay();
void UARTputs(char *data) {
int len, count;
len = strlen(data);
for (count = 0; count < len; count++)
while( !PIR1bits.TXIF );
TXREG = (*(data+count));
}
//Initialise UART port for communication with Computer
EnableUART();
//Start Sending Status message on Port 80 (UART)
SendMessage(StatusMSG1);
void EnableUART ( void )
{
TRISCbits.TRISC6 = 1;
SPBRG = 25; //BR = 9600
TXSTAbits.TXEN = 0;
TXSTAbits.BRGH = 1;
RCSTAbits.SPEN = 1;
BAUDCTLbits.BRG16 = 0;
TXSTAbits.SYNC = 0;
TXSTAbits.TX9 = 0;
INTCONbits.GIE = 0; //Disable interrupts
TXSTAbits.TXEN = 0;
TXSTAbits.TXEN = 1;
}
void SendMessage ( char* Msg )
{
// int len, count;
//
// len = strlen(Msg);
// for (count = 0; count < len; count++)
// while( !PIR1bits.TXIF );
// TXREG = (*(Msg+count));
while( *Msg )
{
TXREG = *Msg;
while( !PIR1bits.TXIF );
Msg++;
}
// TXREG = NEWLINE;
}
#define StatusMSG1 "Booting Started"
const char msg[]= StatusMSG1;
SendMessage(msg);
#define StatusMSG1 "Booting Started"
SendMessage(StatusMSG1);
const char ccBoot [] = "Booting Started";
const char ccError [] = "Booting Error";
const char ccFinish[] = "Booting Finished. The next level Bootloader called!";
SendMessage(ccBoot);
SendMessage(ccError);
I think the key point is not hardware problem.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?