This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using Max232 and sending info to terminial

I have written a simple A/D program to output details to P4 and a seven seg display attached to Port 5. I wish to transmit this information via the RS232 to the terminal emulator (Hypertermial)but I am having problems with the code to set up the UART. So far I have the following working sections in the program (A/D conversion, Binary - BCD)

This is the code I have so far added to attempt the transmission via RS232

void initialise_serial0_for_baudrate()
{
	BD = 1;		//Enable Baud Rate Generator
	PCON = 0x80;  	//Set SMOD to double baudrate
	T1 = 1;		//Initially set transmitt flag
}
	

void Transmit()
{
	T1=0;		//Clear TI flag
	S0BUF = P5;	//Output information
	while(!T1) {;}	//Wait until transmit flag is set
}

The KitCON515C I am using has a 10MHz Quartz.

Any help appreciated to point me in the right direction. I am trying to send using a 9600 baud

  • At a casual glance it appears you have used T1 (T ONE) instead of TI (T I). The Transmit Interrupt bit is labeled TI. Could that be the problem?

    You may want to take a look at the HELLO example program that comes with the Keil tools in the Examples folder. This short program configures the serial port and transmits "Hello World\n".

    Jon

  • See my free 8051 UART driver at http://www.embeddedfw.com for a working serial port initialization.

    If anyone is getting sick of my posting this please tell me and I will stop.

    - Mark

  • "If anyone is getting sick of my posting this please tell me and I will stop."

    I'm sure this is the curse of tech support: no matter how many time you tell 'em, or how clearly you spell it out in the manuals, people will still keep asking the same old questions without first checking if the answer is already at their fingertips! :-(

  • no matter how many time you tell 'em, or how clearly you spell it out in the manuals, people will still keep asking the same old questions without first checking if the answer is already at their fingertips! :-(

    Yep, you are right. But, that's not the real problem. The real problem is trying to quickly identify the customer with a simple problem from the customer with a serious problem.

    Tech support spends MOST of their time with the easiest answers. In many cases, it requires several interactions with the customer to clearly point out the solution. In many cases, the customer is writing their first 8051 application, they don't know C that well, they don't have an emulator, logic analyzer, and they are not proficient on the hardware. So, that only leaves a few places for them to look for the problem-- A) In their code or B) in the compiler.

    The worst types of problems start out with the following: "The program works fine under the simulator. It even runs with the XXX brand emulator. But, it doesn't work when I burn an EPROM and plug it into my hardware. WHAT'S WRONG WITH YOUR COMPILER!"

    It usually takes more than a minute or two to explain that they have just told me that the compiler works fine and they have problems programming an EPROM or FLASH (don't even laugh--it happens all the time) or there is something about their board that doesn't match the simulator or emulator configuration.

    Anyway, on a bright side, last time I checked, about 800 unique visitors check the knowledgebase for answers each day. These are the guys that probably don't call tech support for the simple answers. They get their answers WAY faster than making a phone call.

    Ahh well, as long as you guys keep using our tools, helping out, and pointing out features we should have, the software will only get better and better.

    Jon