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 code for interfacing 89c2051 with max232 circuit

Status
Not open for further replies.

Livingston

Full Member level 2
Joined
Nov 26, 2007
Messages
129
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,298
Location
Chennai-India
Activity points
2,104
minimum circuit of 89c2051

Hai,
I have designed a simple circuit to display some character in the p.c.
That circuit contains one max232 circuit and basic working circuit fo 89c2051(contains 11.0592 crystal with two 33pf and 8,3k ohms and 10µf for reset pin).

The program is executing well (tested with 89c51 controller) but if i programmed the same code in 89c2051 there is no output from the uart

The baurd rate is 9600bps

/*------------------------------------------------------------------------------
Serial.c
------------------------------------------------------------------------------*/

#include <REG52.H> /* special function register declarations */
/* for the intended 8051 derivative */

#include <stdio.h> /* prototype declarations for I/O functions */


#ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
/* is enabled */

/*------------------------------------------------
The delay function
------------------------------------------------*/
void Delay (const unsigned int DELAY)
{
unsigned int x, y;
for (x = 0; x <= DELAY; x++)
{
for (y = 0; y <= 120; y++);
}
}

/*------------------------------------------------
The main C function. Program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void) {

/*------------------------------------------------
Setup the serial port for 9600 baud at 11.0952 MHz.
------------------------------------------------*/
#ifndef MONITOR51
SCON = 0x42; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xFD; /* TH1: reload value for 9600 baud @ 11.0592 MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
#endif

/*------------------------------------------------
Note that an embedded program never exits (because
there is no operating system to return to). It
must loop and execute forever.
------------------------------------------------*/
while (1)
{
P1 ^= 0x01; /* Toggle P1.0 each time we print */
Delay(1000);
printf ("Livingston\n"); /* Print "Livingston" */
}
}
 

execution circuit for 89c51

How much is your code size
89c51 has 8kb of flash while 89c2051 has only 2kb of flash

The baurd rate is 9600mhz

It is not 9600mhz it is 9600bps

Regards
Nandhu
 

89c2051 tmod

curious why not use some frequency such as 8M, 12M, 16M or 20MHz?
 

Re: Interfacing 89c2051

The 89c51 controllers divide the clock frequency by 12 internally.

To achieve minimum errors at all (most of) baud rates the 11.0592 MHz crystal suites the best.

You can also use any other oscillator but with some error in baud rate.

Regards
Nandhu
 

Re: Interfacing 89c2051

Is Port1 toggling as provided for in the code?
 

Re: Interfacing 89c2051

Just to check if the setup is working fine,comment out the printf and see if P1.0 toggles.
 

Re: Interfacing 89c2051

sashijoseph said:
Just to check if the setup is working fine,comment out the printf and see if P1.0 toggles.

But still there is no result.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top