Hi again !
You´re right, the code snippets i posted were not really ok
I updated to newest version and tried again, not better.
Here´s the complete code :
Code: Select all
char msg1[]="Hello World";
unsigned short i;
void main() {
USART_init(19200); // initialize USART module
for(i = 0; i < 11; i++)
Usart_Write(msg1[i]);
}
my Pic is a 16F874A at 4 MHz, programmed with default settings (LVP_OFF, WDT_OFF, HS_OSC).
I´ve read a bit in the Specs of the PIC, the TRMT-Flag only checks if the TSR is empty, but not the TXREG, while PIR1.TXIF signals if the TXREG - Register is empty. could this be the reason for this behaviour ? In fact, the following code works :
Code: Select all
char msg1[]="Hello World";
unsigned short i;
void WriteSerByte(char aChar)
{
while (!PIR1.TXIF) {}
TXREG = aChar;
}
void main() {
USART_init(19200); // initialize USART module
for(i = 0; i < 11; i++)
WriteSerByte(msg1[i]);
}
I know, it´s not programmed clean because i manually take 11 bytes from the string, but that shouldn´t be the problem here..
Perhaps one of the readers could try to test the two programs at the same PIC, i would be very interested in the results.
Greetz
Chris