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

Wed Aug 21 2019, 02:53 AM
charmdatescamreviewsldn
writing
Wed Aug 21 2019, 02:04 AM
charmdatemke
cooking
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html
ExperimenterUK
Thu Jul 11 2019, 07:44 PM
@praveen123. Can you give a link to the project ?
Thu Jul 11 2019, 04:47 PM
ramos
buenos dias alguien podria ayudarme necesito saber como descargar la libreria del l298n para proteus
Thu Jul 11 2019, 11:11 AM
praveen123
anyone can help me

Downloads

Comments

jualanled
Sat Aug 17 2019, 03:41 AM
Wed Aug 07 2019, 10:35 AM
hieu16005
Sat Aug 03 2019, 01:16 PM
Pra
Mon Jul 29 2019, 07:39 AM
manu8193
Wed Jul 24 2019, 04:44 AM
3AAPC
Sun Jul 21 2019, 12:41 AM
rpels7707
Fri Jul 19 2019, 11:31 AM
ameya123
Fri Jul 19 2019, 07:36 AM

Online

Guests: 40, Members: 0 ...

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

Members: 38086
Newest member: jualanled
Forum Activity
nick@IT Avatar
Posted By [email protected]
Wed Aug 07 2019, 10:38 AM
I am trying to execute USSD codes through my GSM m...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Jul 28 2019, 08:55 PM
An LM339 may not be fast enough for reliable SPI ...
sakibnaz Avatar
Posted By sakibnaz
Sun Jul 28 2019, 06:40 AM
Hi All.I need to connect my MCU with an external S...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jul 24 2019, 10:42 PM
Your unit is communicating, so I assume the GPS si...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jul 24 2019, 10:32 PM
Have you read this ?http://www.8051projects.net/wi...
manu8193 Avatar
Posted By manu8193
Wed Jul 24 2019, 04:57 AM
any one tell me the explaination and 'c' code for ...
3AAPC Avatar
Posted By 3AAPC
Sun Jul 21 2019, 12:51 AM
3AAPC Avatar
Posted By 3AAPC
Sun Jul 21 2019, 12:47 AM
With the GPS antenna in the outdoors, I use the ub...
ameya123 Avatar
Posted By ameya123
Fri Jul 19 2019, 07:42 AM
Hello,Please share 8051 Assembly language code for...
figureyang Avatar
Posted By figureyang
Fri Jul 05 2019, 04:37 AM
here is the source code prepared for you download ...