I'm using an 8051/8052 emulator build with Siemens 80c535 uc, and i use uvision2 v2.31 to put the program in. This is a student version of uVision and i'm using it for educational purpose. my goal is to develop a system with serial communication. Problem is that when i try to emulate function printf my emulator is blocked, but on the other hand same thing works with function putchar(printf use putchar). Emulator was build under old version of uVision that worked under DOS and the function printf worked properly. Thnx!
"i try to emulate function printf my emulator is blocked" What exactly do you mean by that? What is "blocked"? Have you tried running it in the simulator?
i mean that the uc is blocked (80c535), i use 80c535 to simulate function of 8051/8052. Thing is that it works in simulator, but when i put my program down to emulator uc is blocked. i think it stays in infinite loop, because not a single byte is send. Program is simply as can be
#include <stdio.h> #include <reg51emu.h> main() { unsigned char q=0; TMOD=0x20 TH1=0xFA; TL1=0xFA; TR1=1; SCON = 0x52; PCON = 0x00; printf("Serija"); while (1){ q=q+1; P1=q; } }
Don't you need to set TI to get the standard Keil printf working? See the "HELLO" example in your Keil\C51\Examples foldre
If you look into register SCON and transform 0x52 into binary code you will get 01010010. LSB is RI, nex to that bit is bit TI and it's set to '1'. If TI is not set ot '1' then the putchar wouldn't work, also thing wouldn't work in the simulator!
Did you already talk to the emulator vendor? How is the serial interface implemented? Reinhard
I found out that the problem is with SFR on 80c535. When I debug code in debugger some information is writed on some locations in SFR on plases where are interrupt flags. I think that printf is not properly translated into hex code or with some bug so my emulator goes to interrupt (don't know witch), but routine is not defined. Emulator was build on my faculty in 1995. I'l just skip printf and write function my self. Thanx to all who tried to help, good luck in your work with uc
Did you enable the serial interrupt? The serial interrupt should be not enabled when you use printf without interrupt controlled serial I/O. Reinhard
Yes i did, program works in simulator but not on the emulator. I'm preety certen that the problem is with keil.