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.

The slave 8051 is not receiving the serial interrupt second time.

Status
Not open for further replies.

scorrpeio

Full Member level 5
Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
Hi...

I am implementing master slave communication using UART between 2 8051.

1. The master 8051 creates a frame of bytes and sends it to slave through UART 9600 8N1.
2. The slave first checks out the address in the received frame and if matches, performs the function specified.
3. The function specified is displaying the byte sequence on the LED matrix in different fashion.
4. To display and scroll it; slave has used Timer0 routine with timer interrupt after every 1msec.
5. At the slave Rx interrupt is high priority and Timer0 interrupt is of low priority.

When I connect the master and slave using 3 wire(Tx, Rx, Gnd) ; I could see the expected result on the LED matrix but for only 1 time

As per the coding, master continuously sends the same frame, so slave should continuously do the same job. But it doesnt happen.

When, I tried debugging using keil simulator, I saw that in slave code, everything works properly. But when actual hardware is connected, I can see the result only for once and then never. :-(

Since four days, I am trying different solutions but yet problem is not resolved.
Please let me know, how should I resolve it.
 

Attachments

  • master.rar
    5.2 KB · Views: 99
  • Slave.rar
    7 KB · Views: 106

When I connected the master to hyperterminal, I could see that same frame is sent continuously to the hyperterminal which indicated that master is also working fine.
 

I only took a look at the slave ISR function, and it looks confused in my opinion.

I don't get the purpose of comparing a buffer index with the data. And the buffer index isn't protected against running out of bounds (> 50).

May be the code is working as doing something useful under special circumstances, but I can't see, what it is.

Code:
uint8_t	u8_RXBuf[50];
uint8_t	u8_Rx_Buf_Index;

void ISR_UART(void) interrupt 4 
{
  if(RX_INTR_FLAG	==	TRUE)
  {
     u8_RXBuf[u8_Rx_Buf_Index] = RX_BUF; //Receive data  
       if( u8_Rx_Buf_Index == (uint8_t)u8_RXBuf[0])
       {
          u8_Rx_Buf_Index = 0;
          if ( u8_RXBuf[0]==u8_RXBuf[u8_Rx_Buf_Index] )
          {
	u1_FLAG_DATA_RECEIVED =	TRUE;
          }
          else 
          {
	u1_FLAG_DATA_RECEIVED =	FALSE; 
           }
       }	
       else
       {
         u8_Rx_Buf_Index++;
       }
    RX_INTR_FLAG = FALSE;	
}
 

Hello,
Thank you for the reply.

The data frame which is created by master looks like this....

Code:
	 Message Format
|------|--------|-------|--------|--------|-------|
|NB--- |-S ADD  |Sc pn  |It cnt  |32Byte- |NB---|
|------|--------|-------|--------|--------|-------|
0	1	   2	3        4	   36	 37

0 th location  NB     - No of Bytes
1st location   S ADD- Slave Address
2nd location  Sc pn -  Scrolling pattern
3rd location   It cnt - Iteration count/Delay count
4-36 location 32 Byte- data byte
37 location - NB      -no of bytes
The purpose of the 1st and last location i.e. NoOfBytes is to ensure that slave has received complete frame. To cross check it, the Buffer index is compared with the that count.
This double check makes it clear that whole frame is received.

Thank you for pointing out about the check point for array exceeding the limit (>50). I will add it now.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top