Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with sending characters to PC via R232

Status
Not open for further replies.

Maverickmax

Advanced Member level 1
Joined
Dec 6, 2004
Messages
404
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,298
Activity points
3,689
Hi

I have been trying to send data to PC via R232 and it works well but it didn't work when I tried to press any letter and I expected my microprocessor to transmit the next letter and it could not work at all. I have used hyperterminal and termv19b and I still get the same effect. could it be my code or what?

Code:
// header files
#include "main.h"
#include "port.h"
#include "delay_loop.h"

//Function Prototypes
void serial_init();



void serial_init()
{
	SCON=0x50;		//Setup for 8-bit data
	TMOD=0x20;		//Setup timer 1 for auto-reload
	TH1=0xF3;		//Setup for 2400 Baud
	TR1=1;			//Turn on timer 1
	TI=1;			//Indicate ready to transmit
}


void main(void)
{

char c;
serial_init();


	while(1)
	{	
	   FIRST_LED=0;	
	   printf("\nEnter a character");
	   c=getchar();
	   c++;
	   printf("The next character is  %c",c);
	   FIRST_LED=1;
	   Delay_Loop(40);		  
	   FIRST_LED=0;
          }
}

Please let me know how to recify this problem

Thank you

Maverick Max
 

Re: Hyperterminal

hi
is your LED blinking and you have not any character in terminal?
i offer you use BASCOM terminal for your test it is better
what is your compiler and your crystal freq.
use CodeVision avr.
 

Re: Hyperterminal

Have you checked the setup for serial communication?
8 bit data, no parity bit, 1 stop bit etc.
Is it matching? Becausse I simulated your code on Keil and is working fine.
Whether your LED blinks?, Increase the delay.
Or you can change the program by simply removing the getchar() and printf() statements.
Use serial interrupt and there you make on and off the LED, so that on hardware you will come to know the problem. Blink the LED while you are transmitting the value of C (Modifed).

Regards
Sarang
 

Hyperterminal

Start with checking the COMport-cable-MAX232-mcu chain continuity.
Start at COMport. Disconnect the cable and short Rx and Tx - pins 2 and 3. Typed characters should echo back.
Now connect cable and short pins 2 and 3 at the end of cable. Then connect the board, pull the mcu (I assume it is socketed), short the Rx and Tx pins in the socket.

If all this works, it's time to check the mcu, the way how it is programmed ("burned"), reset, oscillator...

wek
 

Re: Hyperterminal

Hi

Instead of these printf("The next character is %c",c);

Use Putchar(); function
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top