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

multiprocesor

i have had some hitch when i writed program about multiprocessor communication

- program of master transmit 2 byte (address byte ,data byte ) and program of slave is received data byte but it can't,pleasecheck for me , if it's false please correct or show me how to do ?
thanks very much !!!

.....................
.....................
static data unsigned char databyte=0x40;
static data unsigned char address=0x0F;
static data unsigned char datax;
static void com_isr (void)interrupt 4 using 2
{
if (TI==1)
{
TI=0;
SBUF=datax;
}
}
void main(void)
{ EA=0;
SM0=1; //mode 3
SM1=1;
SM2=1; // mode multiprocessor
REN=1;
PCON &=0x7F;
TMOD=0x20; //...
TH1=0xF3; //baud rate 2400
TR1=1; //....
TI=1;
datax=address;
TB8=1;
EA=1; // enable interrupt
ES=1;
_nop_();
_nop_();
_nop_();
datax=databyte;
TB8=0;
TI=1;
EA=0;
ES=0; // disable interrup because only transmit two byte
while(1)
{}
}
....................................
-Program of slave is received databyte (with address is correct):
...........................
static data unsigned char datax;
static data unsigned char dulieu;
static data unsigned char address;
static void com_isr(void) interrupt 4 using 2
{ if(RB8==1)
{ if (RI==1)
{ RI=0;
address=SBUF; //receive address (the first)
P2=address; //output port2 to test
}
if (address==0x0F) // comprare address
{ SM2=0;
}
else
{ EA=0; //disabled serial port interrrupt
ES=0;
}
}

else
{
if(RI==1)
{ RI=0;
databyte=SBUF; // receive databyte (the second)
P1=dulieu; // output port1 to test
SM2=1;
}
}
}
void main (void)
{
EA=0;
SM0=1; // mode 3 ,uart 9 bit
SM1=1; //....
SM2=1; // multiprocessor
REN=1;
RI=0;
PCON &=0x7F;
TMOD=0x20; // baudrate 2400
TH1=0xF3;
TR1=1;
ES=1;
EA=1;
while (1)
{}
}

Parents
  • "try checking only for RI and not for RB8."

    That won't work: using multiprocessor mode, you must check both RI and RB8 in order to distinguish between address and data bytes!

    The fact that he was testing them in the wrong order has already been noted (6/4/03 1:08:58) and he says he's fixed it! (6/4/03 10:43:56)

Reply
  • "try checking only for RI and not for RB8."

    That won't work: using multiprocessor mode, you must check both RI and RB8 in order to distinguish between address and data bytes!

    The fact that he was testing them in the wrong order has already been noted (6/4/03 1:08:58) and he says he's fixed it! (6/4/03 10:43:56)

Children