Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/02/05 10:57
Read: times


 
#88858 - Post the real code
Responding to: ???'s previous message
putchar(unsigned char ch){
if(bLcd_Flg){
lcd_write(ch);
} else{
SBUF = ch;
}
}


If this is really the code you are using for putchar() there is no way that output via the UART is going to work reliably. You are not waiting for TI before writing to SBUF. Where is the return value from putchar()? Please cut and paste the code you are actually using.

Also, take a look at the code generated below. If you pass an unadorned 5 to printf() only one byte is passed. %d expects a two byte integer, as Keil is big-endian the 5 will be seen as the high byte meaning that the value output will be somewhere between 0x500 and 0x5ff depending what garbage happens to be present in the low byte:

   19:    printf("%d",5);
000425 7BFF              MOV     R3,#0FFH
000427 7A04              MOV     R2,#HIGH 01000420H
000429 7920              MOV     R1,#LOW 01000420H
00042B 750B05            MOV     ?_printf?BYTE+03H,#05H
00042E 1165              ACALL   _printf

   19:    printf("%d",(int)5);
000425 7BFF              MOV     R3,#0FFH
000427 7A04              MOV     R2,#HIGH 01000420H
000429 7920              MOV     R1,#LOW 01000420H
00042B 750B00            MOV     ?_printf?BYTE+03H,#00H
00042E 750C05            MOV     ?_printf?BYTE+04H,#05H
000431 1165              ACALL   _printf




List of 38 messages in thread
TopicAuthorDate
LCD<            01/01/70 00:00      
   must be a bug in lcd_write()            01/01/70 00:00      
      no bug            01/01/70 00:00      
      Bug in lcd_write            01/01/70 00:00      
         Another test            01/01/70 00:00      
         Not quite            01/01/70 00:00      
            Stand corrected            01/01/70 00:00      
               further corrected            01/01/70 00:00      
                  Makes sense            01/01/70 00:00      
                     Delay after the character write?            01/01/70 00:00      
                        unknown bug            01/01/70 00:00      
                           ANSI divergence            01/01/70 00:00      
                              Are you sure?            01/01/70 00:00      
                                 skdjfhg            01/01/70 00:00      
                                    It realy works fine with UART            01/01/70 00:00      
                                       Story so far            01/01/70 00:00      
   Keil and Function pointers?            01/01/70 00:00      
   Simulator            01/01/70 00:00      
      Kaiwalya - O.T            01/01/70 00:00      
         Let me try            01/01/70 00:00      
   Post the real code            01/01/70 00:00      
   Possibilities            01/01/70 00:00      
      ksfd            01/01/70 00:00      
         Troll            01/01/70 00:00      
            the real issue            01/01/70 00:00      
               Corrections            01/01/70 00:00      
               Small but fast            01/01/70 00:00      
                  MIPS            01/01/70 00:00      
            Corrections            01/01/70 00:00      
               sldkjf            01/01/70 00:00      
            dkfuhg            01/01/70 00:00      
               Corrections            01/01/70 00:00      
               Corrections            01/01/70 00:00      
                  got curious and looked            01/01/70 00:00      
               I'm wrong - Damn!            01/01/70 00:00      
                  debugging            01/01/70 00:00      
                     Post you real code            01/01/70 00:00      
   How to initilize 4X20 LCD            01/01/70 00:00      

Back to Subject List