This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How can i get a strings by Scia with interrupts?? Tips need

Hi, I'm working with the Texas TSM320F062, interfacing with Xbee module by UART port. So, I should be capable of capture a string, looks like "7E 00 11 00 46 ....." start byte always it's  0x7E, but I need advice for reliable  system for capture entire strings. Also, it has a variable number of bytes, so I can receipt either 8 or 25 byte.

Then, I have this: 

__interrupt void sciaRxFifoIsr(void)
{
    i++;
    Received_Char = SciaRegs.SCIRXBUF.all;
    SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;  // Clear Overflow flag
    SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
}

In the main void, I wait to recive a 0X7E, then clear counter i. Like this:

ReceivedChar[i] = Received_Char;
    		if (ReceivedChar[i] == 0x7E) {i = 0;}
                Delimiter = ReceivedChar[1];
    		MSB = ReceivedChar[2];
    		LSB = ReceivedChar[3];
    		lenght = MSB + LSB;
    		lenght = lenght + 1;

It's very important for me, know the correct position for the all bytes, how you can see, I used the variable "lenght" for calculate the checksum. But this doesn't works correctly, because some times I loose, the start byte.

best regards

Alejandro

  • Hi,

    But this doesn't works correctly, because some times I loose, the start byte.

    Develop an algo wherein you keep waiting for the start byte and then proceed further for avoiding data loss. (This would be true, if you make sure that data is transmitted continuously such it would atleast capture the next instant)

    Regards,

    Gautam

  • Gautam Iyer said:

    Develop an algo wherein you keep waiting for the start byte and then proceed further for avoiding data loss.

    How I can do, with interrupts? I mean, I can't do this:

    __interrupt void sciaRxFifoIsr(void)
    {
        
        while(SciaRegs.SCIRXBUF.all != 0x7E) { }
        Received_Char = SciaRegs.SCIRXBUF.all;
        i++;
        SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;  // Clear Overflow flag
        SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
    }

    Furthermore, I can't put "while (SciaRegs.SCIRXBUF.all) {}" because I need make other operations.

    Best regards

  • __interrupt void sciaRxFifoIsr(void)
    {
        
      
        Received_Char = SciaRegs.SCIRXBUF.all;
    if(i==0){
        if(Received_Char ==0x7E){
            ReceivedChar[i++] =Received_Char;
        }
    }
    else{
        ReceivedChar[i++] =Received_Char;
        /*you decide 8 or 15 bytes finish
        */
    // for example,8bytes
         if(i==8){
        // Set a flag, 
           str_finish =1;
        }
    
    
    
    
    }
        SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;  // Clear Overflow flag
        SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
    }
    
    
    in main void,
    if(str_finish ==1){
    // your code,checksum calc
    
    
    //
    str_finish =0;
    }
  • Works like a charm!

    but, it need restart i counter

    // for example,8bytes
         if(i==8){
           i = 0; 
           str_finish =1;
        }
    }

    Anyway, thanks a lot!!!