Go Down

Topic: High Bit Rate (Read 205 times) previous topic - next topic

daaz

Jul 10, 2017, 05:39 pm Last Edit: Jul 10, 2017, 11:04 pm by daaz
I am calculating throughput of BLE module using Arduino Mega. Module works on 3.3V so i have Logic Level Shifter between BLE and Arduino. BLE UART is set at 115200 and is sending data at the speed of 64Kbps(verified using CC2540 BLE packet sniffer). Packet send by BLE are in this format in hex:400102030405060708090A0B0C0D0E0F1011121323{40=@,23=#}. I am sending 100 number of packets.Here is the abstract of my code. code works fine for lower bit rate 32Kbps but not for 64Kbs. It does not show any result in this bit rate

Code: [Select]

void loop()
{
   

if(rxflag)
   {
    rxflag = false;
    switch(rxState)
    {

case get_first_header:
      if(rxChar=='@')
      {
       startPoint=millis();
       rxState=get_last_header;
       }
       break;

case get_last_header:
        if(rxChar=='#')
        {
         packetNo++;
         if(packetNo==100)
         {
          endPoint=millis();
          totalTime= endPoint-startPoint;
          Serial.print("Total Time of Packet=");
          Serial.println(totalTime);
         }
         break;
     }
     }
}


void serialEvent1()
{
   if (Serial1.available()>0)
   {
       rxChar = (char)Serial1.read();
       rxflag = true;
   }
}

Robin2

Post your complete program and use the code button </>
Code: [Select]
so your code looks like this and is easy to copy to a text editor. See How to use the Forum

I can't say that I understand what you want help with?

What is sending data to the Arduino?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

horace

at the high bit rate 64Kb/s it is possible that data is arriving faster in serialEvent() than loop() can process the previous byte
why not move the code from loop() into serialEvent() reducing the overhead of passing data between the methods

Robin2

why not move the code from loop() into serialEvent() reducing the overhead of passing data between the methods

Better to dispense with serialEvent() altogether.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up