I'm currently using an PIC18F67J60 to try and print out a string and or an integer value using the UART, but am only getting "00" out of it. I'm somewhat new to embedded C so there's probably something I'm missing realistically.
The function is defined as:
u8 UART_TxMessage(u8 Count, u8 *Bufr)
{
if (Timer_Expired(RxTimer))
{
Timer_Stop(RxTimer);
RxIndex = 0;
}
if (TxCount)
return(0); // still sending last message
if (Count > MAX_MSG)
return(Count);
memcpy(TxBufr,Bufr,Count);
TxIndex = 0;
TxCount = Count;
PIR1bits.TX1IF = 0;
TXREG1 = Count;
PIE1bits.TX1IE = 1;
return(Count);
}
The only way I've been able to get anything other than "00" is by echoing back what's been recieved on the Rx side; so I'm confident it's just my lack of knowledge.
I'd really appreciate any examples!
ISR Function as requested:
void UART_ISR()
{
u8 c;
if (PIR1bits.TX1IF && PIE1bits.TX1IE)
{
PIR1bits.TX1IF = 0;
if (TxIndex < TxCount)
{
TXREG1 = TxBufr[TxIndex++];
} else {
PIE1bits.TX1IE = 0;
}
}
if (PIR1bits.RC1IF)
{
Timer_Set(RxTimer,100);
PIR1bits.RC1IF = 0;
c = RCREG1;
if (RxCount)
return; // buffer in use
if (RxIndex >= MAX_MSG)
{
RxIndex = 0; // abort
return;
}
RxBufr[RxIndex++] = c;
}
}