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

printf does not work on microcontroller

I have a very simple but annoying problem. I use printf () in my code and either on Keil or Proteus simulations it works. However, when I load this code to my microcontroller, which is DS89C450, it does not work.I also add the putchar.c and getkey.c to my source code. Characters, observed on Terminal Emulator are dots and squares and sometimes endless loops. The baud rate is correct. I test it by sending characters via SBUF0. The code is right here.

#include <DS89C4xx.H>
#include <stdio.h>

void main (void)
{
  SCON0=0x50;
  TMOD=0x20;
  TH1=0xFC; //9600 bps with 14.7456 MHz crystal
  TR1=1;
  TI_0=1;
   while (1)
  {     printf ("test\n");
}

Parents
  • I have a very simple but annoying problem. I use printf () in my code and either on Keil or Proteus simulations it works. However, when I load this code to my microcontroller, which is DS89C450, it does not work.
    you say nothing about your hardware, but I do hope you have a MAX232(equivalent) correctly implemented between the uC and the PC.
    One poster a long time ago had the same problem and it was using the wrong capacitor values.

    since it works on the simulator, I guess hardware or baudrate error.

    Erik

Reply
  • I have a very simple but annoying problem. I use printf () in my code and either on Keil or Proteus simulations it works. However, when I load this code to my microcontroller, which is DS89C450, it does not work.
    you say nothing about your hardware, but I do hope you have a MAX232(equivalent) correctly implemented between the uC and the PC.
    One poster a long time ago had the same problem and it was using the wrong capacitor values.

    since it works on the simulator, I guess hardware or baudrate error.

    Erik

Children
No data