SCI port data Overrun problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SCI port data Overrun problem

1,149 Views
Ryu
Contributor I
Hi.

I'm trying to receive data on an EVB9S12NE64 board's SCI1 port, and transmit them periodically on the Network.
Everything seems to work fine, but only a little problem.
Out of the ~2048 data values arriving to the SCI1 port, around 60 of them are lost.
I've implemented an ISR with Fifo for my SCI1 receiver, set it to high priority ( HPRIO = 0xD4; ), and removed any additional DEBUGOUT functions I placed for debugging purposes, as they proved to cause even greater data loss before.
Basically I believe the loss is caused by the CPU being busy preparing and transmitting a UDP packet for every 50 received values.
I'm operating the port at 19200 BAUD rate. I also tried 9200, but still the same problem. If everything works out, hopefully I will be able to increase the BAUD rate even further, to decrease the delay time of receiving the date.
Any ideas how I fix this problem?
If it helps, please find below my SCI1in -> UDP function.

Thanks

//--------Read Sensor Data----

void read_sensor(void){
  UINT16 i=0;
  UINT16 tempi=0;
  UINT8 pkno=0;
  UINT16 datalen = 0;

  RxFifo_Init(); //Reset fifo's contents
 
  SCI1OutString("SendMeData\n\r"); //Request data for a single Scan

  character = SCI1In();
  while (character != CR){ //Read all characters of a scan til CR
 
        net_buf[UDP_APP_OFFSET+tempi+5] = character; //Add character to buffer
        tempi++;
        if (character == SP){
          i++;
          if (i%50 == 0){ //Packetize and Tx every 50 pixels
              datalen=tempi+5;
              tempi = 0;       net_buf[UDP_APP_OFFSET+tempi]='R';
              tempi = 1;       net_buf[UDP_APP_OFFSET+tempi]='Y';
              tempi = 2;       net_buf[UDP_APP_OFFSET+tempi]='U';
              tempi = 3;       net_buf[UDP_APP_OFFSET+tempi]=(pkno+48);
              tempi = 4;       net_buf[UDP_APP_OFFSET+tempi]='@';
             
             
              // UDP Send 50 pixels

(void)udp_send(udp_demo_soch,UDP_DEMO_RMTHOST_IP,UDP_DEMO_RMTHOST_PRT,net_buf+UDP_APP_OFFSET,NETWORK_TX_BUFFER_SIZE-UDP_APP_OFFSET,datalen);
              pkno++;
              tempi=0;
          }
        }
        character = SCI1In();
      if (i>res){
        break; // Resolution value reached and no CR found
      }
    }
    //CR Found

  datalen = tempi+5;

  //Send remaining readings 
  tempi = 0;       net_buf[UDP_APP_OFFSET+tempi]='R';
  tempi = 1;       net_buf[UDP_APP_OFFSET+tempi]='Y';
  tempi = 2;       net_buf[UDP_APP_OFFSET+tempi]='U';
  tempi = 3;       net_buf[UDP_APP_OFFSET+tempi]=47;
  tempi = 4;       net_buf[UDP_APP_OFFSET+tempi]='@';
  (void)udp_send(udp_demo_soch,UDP_DEMO_RMTHOST_IP,UDP_DEMO_RMTHOST_PRT,net_buf+UDP_APP_OFFSET,NETWORK_TX_BUFFER_SIZE-UDP_APP_OFFSET,datalen);
  Debugi(pkno+1); 
  Debugt(" Packets sent over UDP>>>>>>>>>\n\r"); 
}
Labels (1)
0 Kudos
1 Reply

326 Views
Ryu
Contributor I
I have an update to my problem.

After monitoring the data received over the Network, it appears that no characters are skipped at the SCI port, but for some very weird reason, some of the UDP packets received are missing specifically a space (0x20) character, at a specific position!

eg
UDP datagram at the PC in ASCII:
RYU/@19245 185540579 4996 21920 41441 3893 43648 9227 45783 4325 50770 754 39169 57632 8341 40500 59394 19361 37279 24988 17704 17154 19508


(Each of the values above should not exceed the value of a 16bit integer.)
This only happens in some of the packets, and ALWAYS between the 2nd and 3rd number! Especially if you consider that all the values are stored and transmitted 1-by-1 character, it's a bit weird that it's ALWAYS the space missing!
I'm confused. I don't why my problem occurs so selectively.
What can be causing this?

Thank you in advance
0 Kudos