This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

putchar problem with S0TIR

#include <stdio.h>
#include <reg165.h>

signed char putchar (signed char c) {
if (c == '\n') {
while (!S0TIR);
S0TIR = 0;
S0TBUF = 0x0d; /* output CR */
}
while (!S0TIR);
S0TIR = 0;
return (S0TBUF = c);
}

/* main program */
/****************/
void main (void) {
#if 0 //THIS CODE IS DISABLED
#ifndef MCB167 /* do not initialize if you use Monitor-166 */
P3 |= 0x0400; /* SET PORT 3.10 OUTPUT LATCH (TXD) */
DP3 |= 0x0400; /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT) */
DP3 &= 0xF7FF; /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
S0TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */
S0RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */
S0BG = 0x40; /* SET BAUDRATE TO 9600 BAUD */
S0CON = 0x8011; /* SET SERIAL MODE */
#endif
#endif

S0TIE = 0 ;
S0TIR = 1 ;
S0TBUF = 0X45 ;
putchar('A') ;
putchar('\n') ;
putchar('A') ;
while (1) {
}
}


Can somebody tell me Why the above code is not giving the following output with 165Utah CPU?
EA
A