Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/01/09 10:11
Read: times


 
#164143 - Interrupt Priority in Multiprocessor Communication 8051
Hi,
I am having one more system which runs with multiprocessor communication. The communication is established between Master 8052 controller system and 12 Slave 8052 controller systems. All the RI pins of Slaves are hardwired together to a common line. The serial port is operating in Mode 3 with variable baud rate 31250 set. Each slave is recognized by a 4-bit hardware ID generated as per its placement from the Master system.

Data transmission from Master to Slave is whenever needed, but the vice versa is based upon a round robin sequence of reception from addressed Slave. All data byte streams have Start and End bytes, and all bytes are acknowledged.

I made use of the multiprocessor communication of basic 8051 core, which is as follows:

When the master processor wants to transmit a block of data to one
of several slaves, it first sends out an address byte which identifies
the target slave. An address byte differs from a data byte in that the
9th bit is 1 in an address byte and 0 in a data byte. With SM2 = 1, no
slave will be interrupted by a data byte. An address byte, however,
will interrupt all slaves, so that each slave can examine the received
byte and see if it is being addressed. The addressed slave will clear
its SM2 bit and prepare to receive the data bytes that will be coming.
The slaves that weren’t being addressed leave their SM2s set and
go on about their business, ignoring the coming data bytes.

Master code: Crystal = 12Mhz.
	/* Mode 3: 9-bit uart, VARIABLE 31250 baud rate */
	TH1  = 	0xFE; 
	TB8 = 1;
	REN = 1;
	RB8 = 0;

	/*This function addresses a particular slave and makes it ready for data reception*/


	void delay(void)
	{
		unsigned char i;
		for(i=255;i;i--) ;
	}

	void enableSlaveToReceive(unsigned char slave_id)
	{
		TB8 = 1;	    /* set bit 8, for address transmission */
		SBUF = (sid | 0x10);/* General Broadcast address - all slaves receive this */
		delay();  /* short delay to give time for slave to check address
			    and switch over from address to data reception mode*/	
	}

	/*The addressed slave becomes ready and starts receiving forthcoming data bytes thro this function*/

	void sendData(unsigned char i)
	{
		TB8 = 0;	/* address sent, now set for data transmission */
		SBUF = i ;	/* send acknowledged data */		
	}


 

Slave code:
	TH1  = 	0xFE;	                // 31250 BAUD RATE (Crystal = 6Mhz)	 
	SM2 =1;
	RB8 = 0;
	TB8 = 0;
	REN = 1;

	unsigned char rec_data;		//TEMPORARY BUFFER TO HOLD RECEIVED BYTE
	unsigned char volatile HW_ID;	//THE 4-BIT ID OF THIS SLAVE(0-11)

	void onSerialPortISR(void) interrupt 4 using 3
	{
		EA = 0;		//DISABLING ALL INTERRUPTS
		if(RI)// IF DATA RECEIVED
		{						
			rec_data = SBUF;    // TAKE THE DATA IN TO THE TEMP BUF       
			if(RB8)   // IF IT IS ADDRESS BYTE 
			{
				if(HW_ID == (rec_data & 0x0f)) 	//if address matches	
					SM2 = 0;//THIS ADDRESSED SLAVE CLEARS SM2
				else 
					SM2 = 1;//THIS IS UNADDRESSED SLAVE
				RB8 = 0;
			}
			else if(!SM2)//IF IT IS A DATA BYTE
			{
				--
				--	//MAKE USE OF THE RECEIVED DATA BYTES
				--
			}
			RI = 0;			// IF DATA RECEIVED, CLEAR THE FLAGS
		}
		if(TI)// IF DATA TRANSMITTED, CLEAR THE FLAGS					
		{						
			TI = 0;
		}
		EA = 1;		//ENABLING INTERRUPTS
	}

 


I am also using Timer 0 Interrupt service routine in Mode 1 in the Slave system code, running with 20 milliseconds ticks. The routine is:


	void onTimerISR(void) interrupt 1 using 1
	{
		unsigned char i;

		EA = 0;		//DISABLING ALL INTERRUPTS

		TR0 = 0;	//TIMER 0 RUN BIT = 0
		TH0 = 0xB1;	//MANUAL RELOAD VALUES IN
		TL0 = 0xC0;	//TL0,TH0 OF TIMER 0 FOR COUNTING 20 MILLISECONDS AGAIN
		TR0 = 1;	//START TIMER 0 RUN BIT

		--		// 
		--		// REMAINING CODE IN TISR ROUTINE...
		--		//

		ET0 = 1;	//TIMER 0 INTERRUPT ENABLING

		EA = 1;		//ENABLE ALL INTERRUPTS
	}

 


The Serial Interrupt Routine plays a major role here to receive data bytes from addressed slave in a Round Robin Sequence in the superloop forever, and it is communicating at 31250 Baud. This high speed is used because the total system is a distributed one with communication between 8052 controllers. I had removed disabling interrupts in ISR's. The Slave system also has these 2 highly active Interrupts defined at its end.


Q: If the Timer 0 Interrupt and Serial Interrupt are highly active in this system, what will be the impact on the priorities between them in runtime if I remove disable/enable EA in ISR's in both Master and Slave Systems?
Is there any method to control and balance these 2 Interrupts in this project?

thanks in advance.






List of 4 messages in thread
TopicAuthorDate
Interrupt Priority in Multiprocessor Communication 8051            01/01/70 00:00      
   Automatic Address Recognition            01/01/70 00:00      
   if they have the same priority set...            01/01/70 00:00      
   use the IP SFR            01/01/70 00:00      

Back to Subject List