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) {} }
That would be "<pre>" and "</pre>" tags. Those will preserve the indentation in code and make it easier to read.
Hmm... They showed up literally in the preview...
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 run,please check 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 while(1) {} } .................................... -Program of slave is received databyte (with address is correct): ........................... static data unsigned char datax; static data unsigned char databyte; 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 ES=0; //interrrupt } } else { if(RI==1) { RI=0; databyte=SBUF; // receive databyte // (the second) P1=databyte; // 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) {} }
Ah - that's better!! Please describe more clearly exactly what is & is not happening * is the master actually transmitting? * is the master correctly setting the 9th bit? * is the receiver receiving anything at all? * is the receiver ISR ever called? etc, etc... One thing: In your receiver ISR, you are checking RB8 before RI - that's the wrong order.
Did you read Intel Application Note AP-410, "Enhanced Serial Port on the 83C51FA" http://www.intel.com/design/mcs51/applnots/270490.htm, as I suggested in your previous thread: http://www.keil.com/forum/docs/thread2849.asp
I have found error ? because i have checked RB8 before RI ,I have repaired but now i have a question : - I want transmit data from slave to master .Have the slave to multiprocessor mode or other mode ? when two slave send data how to do ? please help me ! thanks...
I want transmit data from slave to master .Have the slave to multiprocessor mode or other mode ? when two slave send data how to do ? In a round robin (or priority if required) have the master ask the slaves "do you have data". If the slave respond "yes" the master will change to receive and receive data till a "done" message is received from the slave. In some designs it is better to allow the slaves to send opnly one record when responding "yes". Erik
"when two slave send data how to do?" You must ensure that they don't try to send at the same time - because they will corrupt each other's data!! (known as a "collision"). Normally, as Erik suggests, you would never allow any slave to send any unsolicited data - a slave would only ever transmit in response to a message from the master. Therefore, the Master has to "poll" each Slave to obtain any data it may have to transmit. All devices on the bus must be configured for multiprocessor mode, but only the slaves need to do the address matching - the master doesn't need an address because, by definition, there is only one Master! Some systems make use of the 9th bit in a Slave transmission to mark the end of the message.
-How is it that the master can "poll" " each Slave to obtain any data it may have to transmit.I think it's dificult . -How is it that the slave can response to a message from the master.what's it base on ? ..please show me more clearly or send for me some example ! ThankS...
"How is it that the master can 'poll' each Slave" The poll is just a suitably-addressed command that the master sends to each slave "How is it that the slave can response to a message from the master" Having received the "poll" (or other command), the slave just sends a response. The master will not start the next poll (for the next slave) until it has received this response. You will have to define what constitutes a "poll" message, and the format of the response (including provision for an "I'm OK, but nothing to say just now" response)
try checking only for RI and not for RB8. I think it will help you in tracking your problem. (veni).
"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)
There are derivatives out there e.g. the Rx2 that can be programmed to generate RI only on address match. Erik
"There are derivatives out there e.g. the Rx2 that can be programmed to generate RI only on address match." Yes: for details see the Intel Application Note AP-410, "Enhanced Serial Port on the 83C51FA" mentioned earlier. But you still need to check RB8 to see if you got the RI because of data or address - and, of course, to catch any protocol problems with bit9 set where it didn't oughta be!