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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/09/09 09:28
Read: times


 
#165194 - Program runs really slow
Hi, I'm programming using Keil μVision 3 for 8051. I use the examples inside the folders to test to see how fast they run. The sample program runs really fast but when I code a simple program to run through the emulator it runs very very very slow. Am I doing something wrong? Here's my sample code:

#include<stdio.h>
#include <reg51.h>

main ()
{
int ch;

SCON = 0x52; // serial port configuration
TMOD = 0x20;
TCON = 0x40;
TH1 = 0xf3; // 2403 baudrate @12mhz

printf("Please type in one character:n");
ch=getchar();
printf("nThe character you just entered is: %cn", ch);
return 0;
}

I try to stick with the C syntax as much as possible but it just keeps crashing. I wrote 2 or 3 functions and split the code up from main() but it still doesn't work correctly or if it does it'll pickup the input and go really really slow. It took about 15-30 seconds to get one char. Any help into the right direction would be great. I know C++ but I don't know C syntax very well.

List of 5 messages in thread
TopicAuthorDate
Program runs really slow            01/01/70 00:00      
   More detail required            01/01/70 00:00      
      RE: Andy            01/01/70 00:00      
         You are reading the wrong book!            01/01/70 00:00      
         program will not compile            01/01/70 00:00      

Back to Subject List