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

Problem SBUF 8051

Hello everybody.

I'm french, so sorry for my english.

First, thanks for all gentlemens who will help me.

I follow a formation about programmation microcontroleur 8051's family.

First I have studied the microcontroleur himself, after I have made a lot of programs in assembleur with Keil, and no problem.

After I have learn the langage C, and I have made a lot of program on my computer for the computer, and now I try to made the same previous program that I have created in assembleur but in langage C, always with Keil, and I have a problem.

The problem is that the hyperterminal diplay :

"Serial number : 1’˜ž¤ª"

instead of display "Serial number : 111111".

The problem is when the program call the fonction VERIFTI(), the veriable unite is lost!!!!
Why ?????

Do you have an idea?

My microcontroleur is an NXP P89V51RD2BN

Please look at my program:


#include <REG51.H>

void VERIFRI()reentrant;
void VERIFTI()reentrant;

data unsigned char cent;
data unsigned char diz;
data unsigned char unite;


void Led_chenillard()
{



SM0=0;                          //UART en mode 1
SM1=1;                          //UART en mode 1
SM2=0;                          //Gestion multiprocesseur inactive
REN=1;                          //Reception active

TMOD=0x20;                      //Config Timer 1 en mode 2 et mode temporisateur
TH1=255;                        //56000 Bauds
TR1=1;                          //Active le timer 1

TI=1;



SBUF=0x0C;                  //Efface écran
VERIFTI();                      //Vérifie si l'envoie au PC est terminé


SBUF='S';
VERIFTI();

SBUF='e';
VERIFTI();

SBUF='r';
VERIFTI();

SBUF='i';
VERIFTI();

SBUF='a';
VERIFTI();

SBUF='lk';
VERIFTI();

SBUF=' ';
VERIFTI();

SBUF='n';
VERIFTI();

SBUF='u';
VERIFTI();

SBUF='m';
VERIFTI();

SBUF='b';
VERIFTI();

SBUF='e';
VERIFTI();

SBUF='r';
VERIFTI();

SBUF=' ';
VERIFTI();

SBUF=':';
VERIFTI();

SBUF=' ';
VERIFTI();

unite='1';

SBUF=unite;
VERIFTI();

SBUF=unite;
VERIFTI();

SBUF=unite;
VERIFTI();

SBUF=unite;
VERIFTI();

SBUF=unite;
VERIFTI();

SBUF=unite;
VERIFTI();

FIN:
goto FIN;

}



void VERIFRI()reentrant
{
        DEBUT:
        if (RI==0)
        {
        goto DEBUT;
        }

        else
        {
        RI=0;
        }
}

void VERIFTI()reentrant
{
        DEBUT:
        if (TI==0)
        {
        goto DEBUT;
        }

        else
        {
        TI=0;
        }
}