AnsweredAssumed Answered

STM32F103 Sweep frequency

Question asked by cobiella_ruiz.federi on Aug 5, 2016
Latest reply on Aug 8, 2016 by Rygel.Troy1818
Hi im newbie with this mcu, and im try to doing a sweep of frequency with TIM3 and the chanel1, A6. my main code its the next 
while (1)
  {
        unsigned int i=0, j=0, h=0;
        for(i = FrequencyStart; i < (FrequencyStart+FrequencySweep); i++){
            Frequency = i;
            TIM_TimeBaseStructure.TIM_Period = Frequency;
            TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
             
            TIM_OCInitStructure.TIM_Pulse = (Frequency/2);
            TIM_OC1Init(TIM3, &TIM_OCInitStructure);
                         
            for(j = 0; j < 0x2AFF; j++){;}
        }
        for(h = (FrequencyStart+FrequencySweep); h > FrequencyStart; h--){
            Frequency = h;
            TIM_TimeBaseStructure.TIM_Period = Frequency;
            TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
             
            TIM_OCInitStructure.TIM_Pulse = (Frequency/2);
            TIM_OC1Init(TIM3, &TIM_OCInitStructure);
                         
            for(j = 0; j < 0x2AFF; j++){;}
        }
    }

This make me the sweep frequency fine but the signal have a little errors around each 1370us look the photo
osc1.JPG
osc2.JPG
If some body can helpme the prevent this and obtain a clean signal i will apretiate it.
Thanks

Outcomes