AnsweredAssumed Answered

STM32f3, how to increase speed communication

Question asked by modjo on Mar 8, 2014
Hi, like another people i configure a vpc com with my stm32f3. For that i modify the demonstration example to add cdc class. But now i want to increase the com and i would like to have some explanation (and advise). At first the code :

Demo_CompassConfig();
     
    //Waiting User Button is pressed
    while (UserButtonPressed == 0x01)
    {
      //Wait for data ready
      while(DataReady !=0x05)
      {}
      DataReady = 0x00;
       
      //Read Compass data
      Demo_CompassReadMag(MagBuffer);
      Demo_CompassReadAcc(AccBuffer);
       
      for(i=0;i<3;i++)
        AccBuffer[i] /= 100.0f;
       
     fNormAcc = sqrt((AccBuffer[0]*AccBuffer[0])+(AccBuffer[1]*AccBuffer[1])+(AccBuffer[2]*AccBuffer[2]));
       
      fSinRoll = -AccBuffer[1]/fNormAcc;
      fCosRoll = sqrt(1.0-(fSinRoll * fSinRoll));
      fSinPitch = AccBuffer[0]/fNormAcc;
      fCosPitch = sqrt(1.0-(fSinPitch * fSinPitch));
     if ( fSinRoll >0)
     {
       if (fCosRoll>0)
       {
         RollAng = acos(fCosRoll)*180/PI;
       }
       else
       {
         RollAng = acos(fCosRoll)*180/PI + 180;
       }
     }
     else
     {
       if (fCosRoll>0)
       {
         RollAng = acos(fCosRoll)*180/PI + 360;
       }
       else
       {
         RollAng = acos(fCosRoll)*180/PI + 180;
       }
     }
      
      if ( fSinPitch >0)
     {
       if (fCosPitch>0)
       {
            PitchAng = acos(fCosPitch)*180/PI;
       }
       else
       {
          PitchAng = acos(fCosPitch)*180/PI + 180;
       }
     }
     else
     {
       if (fCosPitch>0)
       {
            PitchAng = acos(fCosPitch)*180/PI + 360;
       }
       else
       {
          PitchAng = acos(fCosPitch)*180/PI + 180;
       }
     }
 
      if (RollAng >=360)
      {
        RollAng = RollAng - 360;
      }
       
      if (PitchAng >=360)
      {
        PitchAng = PitchAng - 360;
      }
             
            fTiltedX = MagBuffer[0]*fCosPitch+MagBuffer[2]*fSinPitch;
      fTiltedY = MagBuffer[0]*fSinRoll*fSinPitch+MagBuffer[1]*fCosRoll-MagBuffer[1]*fSinRoll*fCosPitch;
       
      HeadingValue = (float) ((atan2f((float)fTiltedY,(float)fTiltedX))*180)/PI;
       
      if (bDeviceState == CONFIGURED)
        {
                float_t TabKs=RollAng;
                uint8_t *ptr_Ks=(uint8_t*)&TabKs;
                uint8_t Lentgh_Ks=sizeof(TabKs);
                CDC_Send_DATA(ptr_Ks, Lentgh_Ks);
                STM_EVAL_LEDOn(LED6);
        }
         
        else
        {
            STM_EVAL_LEDOff(LED6);
        }
 
    }
        UserButtonPressed = 0x00;
  }
}

definition of systick in the main :

/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

the handler :

void SysTick_Handler(void)
{
  TimingDelay_Decrement();
  USBConnectTimeOut--;
  DataReady ++;
}

If i understand the dataReady is for wait 50ms (systick interrupt every 10ms and increment a counter while dataReady is equal to 5), this mean a frequents of 20Hz. Why they define a delay of 50 ms ? If i would like to refresh the value each 10 ms, how i can proceed ? i tried to replace
while(DataReady !=0x05)
 
//by
 
while(DataReady !=0x01)
 but after a moment (2s) i loose some data ..

How can i proceed to increase the send of data ?

Outcomes