hi, I am using a 8051 microcontroller in my project. The purpose of the project is to count the pulses using a controller. I have configured 8051 in the counter mode and the counted value is being sent to the hyper terminal with the help of RS-232 serial port. In the simulation process of my program I was getting the exact counted value in SBUF register but while practically implementing it I am getting the output as extended standard ASCII characters instead of my desirable count.
my program is given below and it is written in C and simulated in Keil microvision. So anybody who could help me out in this problem please refer your suggestions.!!!!!!!!!!!!!!!!!!!!!
#include <reg51.h> //delay function
void sdelay(int stime) { unsigned int i,j,k; for(i=0;i<stime;i++) { for(k=0;k<1000;k++) for(j=0;j<131;j++); } } // heart bit counting function
int heart_bit() { int count; { TL0=0; TH0=0; TR0=1; sdelay(60); count=TL0; TR0=0; TF0=0; return (count); } } void serial_send() { unsigned char welcome[]="iCARE welcomes you"; int i; TR1=1 ; for(i=0;i<18;i++) { SBUF=welcome[i]; while(TI==0); TI=0; } } //record send void record_send(int record) { TR1=1; SBUF=record; while(TI==0); TI=0; } void main() { int count; T0=1; TMOD=0x26; SCON=0x50; TH1=0xFD; serial_send(); sdelay(20); count=heart_bit(); record_send(count); while(1); }