Discussion in "8051 Discussion Forum" started by    Ansh12    Feb 25, 2018.
Sun Feb 25 2018, 04:36 PM
#1
I want to see character back to terminal whatever I type on terminal. My code is not working

#include <reg51.h>


void uart_init();          
char getc();              
void putc (char c);          
void puts(char *s);        

void uart_init()                  // Initializes UART peripheral
{
  TMOD = 0x20;                    // Timer1, mode 2
  TH1  = 0xFD;                    // 9600 bps 11059200 Clock, core(12cycle), uart(SMOD=0)
  TL1  = 0xFD;                    // First byte timing
  SCON = 0x52;                    // 0x52 : 0101 0010  Receive Enable, TI as 1 (set as ready)
  TR1  = 1;
}

char getc()                       // Polled method to Receive a byte(8bit)
{
  while (RI == 0);                // Wait until a byte has been received                        
  RI = 0;                         // Acknowledge RI
  return SBUF;                   
}

void putc (char c)           
{
  while (TI == 0);                                  
  SBUF = c;                      
	
}

void puts(char *s)           // Typical puts for uart Transmit a string-null-terminated
{
  while (*s!=0)                   // Check for null byte termination
  putc(*s++);                // and send each byte using uart
}


void main ()
{
   char c;

   uart_init();             // Init UART to desired settings
   puts("Anssh");

   while (1) 
	{                         // This loop echoes back whatever is typed on PC Keyboard
     c = getc();            //    get next byte from PC
     putc(c);               //    and send it back as echo
  }

}

How to get echo character on terminal?

Attachment
Sun Feb 25 2018, 10:51 PM
#2
You need to reset TI

void putc (char c)           
{
  while (TI == 0);                                  
  TI = 0;
  SBUF = c;                      
}
 
 Ansh12 like this.
Mon Feb 26 2018, 01:28 AM
#3


You need to reset TI

ExperimenterUK



Can you give a little more information about this. How to do it ?
Tue Feb 27 2018, 10:52 PM
#4
Use the code in my last post.
Tue Feb 27 2018, 11:28 PM
#5


Use the code in my last post.

ExperimenterUK


I did but code is not working
#include <reg51.h>

 
 
void uart_init();          
char getc();              
void putc (char c);          
void puts(char *s);        
 
void uart_init()                  // Initializes UART peripheral
{
  TMOD = 0x20;                    // Timer1, mode 2
  TH1  = 0xFD;                    // 9600 bps 11059200 Clock, core(12cycle), uart(SMOD=0)
  TL1  = 0xFD;                    // First byte timing
  SCON = 0x52;                    // 0x52 : 0101 0010  Receive Enable, TI as 1 (set as ready)
  TR1  = 1;
}
 
char getc()                       // Polled method to Receive a byte(8bit)
{
  while (RI == 0);                // Wait until a byte has been received                        
  RI = 0;                         // Acknowledge RI
  return SBUF;                   
}
 

 
void putc (char c)           
{
  while (TI == 0);                                  
  TI = 0;
  SBUF = c;                      
}
 
void puts(char *s)           // Typical puts for uart Transmit a string-null-terminated
{
  while (*s!=0)                   // Check for null byte termination
  putc(*s++);                // and send each byte using uart
}
 
 
void main ()
{
   char c;
 
   uart_init();             // Init UART to desired settings
   puts("Anssh");
 
   while (1) 
	{                         // This loop echoes back whatever is typed on PC Keyboard
     c = getc();            //    get next byte from PC
     putc(c);               //    and send it back as echo
  }
 
}
Wed Feb 28 2018, 12:15 AM
#6
I tested the code you posted in Proteus and it works.
Be sure Proteus is loading the correct code.
If it still does not work, post your Proteus and Keil files.
Wed Feb 28 2018, 12:41 AM
#7


I tested the code you posted in Proteus and it works.
Be sure Proteus is loading the correct code.
If it still does not work, post your Proteus and Keil files.

ExperimenterUK


Please look at the attached file

Attachment
Wed Feb 28 2018, 01:48 AM
#8
In the rar file you just posted,
the routine "void putc (char c) "
does not contain the line "TI=0;"
Add it.
Wed Feb 28 2018, 03:32 AM
#9


In the rar file you just posted,
the routine "void putc (char c) "
does not contain the line "TI=0;"
Add it.

ExperimenterUK


sorry for posting wrong file but still I am not getting echo character

look at this file
Attachment
Wed Feb 28 2018, 10:12 PM
#10
TI= 0 is still missing
from putc (char c)

Get Social

Information

Powered by e107 Forum System

Conversation

DragonDad
Wed May 29 2019, 12:17 PM
Hi. Who is online?
Tue May 21 2019, 09:53 PM
Jayson Contreras
Hello
Xkalebar
Mon May 06 2019, 06:21 AM
Please provide me the code for gsm based sms controlled notice board
ExperimenterUK
Mon Apr 22 2019, 08:07 PM
@hassan malik post your problem in the "General help Guidance and Discussion" forum
Mon Apr 22 2019, 02:21 PM
RAJESH MAPARi
please send me code to interface atmega32 with 24c1024 serial eeprom
Mon Apr 22 2019, 10:48 AM
hassan malik
hello sir i installed proteus 7.8 professional on window 7 ultimate and window 10 but there would be same errors onn both windows. the error is bad license key.please any one help me
Mon Apr 22 2019, 10:47 AM
hassan malik
hello sir i installed proteus 7.8 professional on window 7 ultimate and window 10 but there would be same errors onn both windows. the error is bad license key.
ExperimenterUK
Sun Apr 14 2019, 03:14 PM
@deshrar. Please post your question in 8051 forum
Sun Apr 14 2019, 04:58 AM
deshraj
hallo mam.. i have downloded gsm notice board code its running fine on lcd but how so send msg to the module . i mean format of password and msg.. thank you
kevinharsha
Thu Apr 11 2019, 01:53 PM
Can i see the circuit diagram for the music tone library 8051 project?

Downloads

Comments

DragonDad
Tue May 21 2019, 02:50 PM
dhiyamtech
Thu May 09 2019, 10:20 AM
harsha.reddy
Fri May 03 2019, 09:02 AM
soumen1963
Fri May 03 2019, 06:01 AM
Vasily
Mon Apr 29 2019, 04:03 AM
Xkalebar
Sun Apr 28 2019, 08:59 AM
obibikwe
Fri Apr 19 2019, 05:55 PM
gigyani
Thu Apr 18 2019, 01:43 AM

Online

Guests: 49, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38066
Newest member: DragonDad
Forum Activity
Ansh12 Avatar
Posted By Ansh12
Sun Apr 28 2019, 02:15 PM
I made a minor change, it works in Proteus.Try the...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 25 2019, 08:20 PM
I made a minor change, it works in Proteus.Try the...
gigyani Avatar
Posted By gigyani
Thu Apr 25 2019, 01:17 AM
when i add cufirst.hex its not working.after 2-3 s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Apr 24 2019, 12:29 AM
http://www.8051projects.net/download-d205-electron...
gigyani Avatar
Posted By gigyani
Tue Apr 23 2019, 09:22 PM
How to enter the electronic voting machine into vo...
Ansh12 Avatar
Posted By Ansh12
Mon Apr 22 2019, 09:12 AM
Then flash the led when you get any input on B0.Le...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Apr 19 2019, 05:35 PM
The full error is control_unit.asm(1294): error A4...
gigyani Avatar
Posted By gigyani
Thu Apr 18 2019, 10:09 PM
I'm using keil uvision5. attached is the rar file ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 18 2019, 04:58 PM
Please zip your full code and post it.Which assemb...
gigyani Avatar
Posted By gigyani
Thu Apr 18 2019, 02:01 AM
STATREAD:MOV A, #WTCMD ;LOAD WRITE CO...