2014-07-11 07:14 AM
Dear sir,
i have following conditions.the problem is that, my actual value & compiler value are not matching.in debug options.1) i am getting duty cycle on o.scope less than 2% the actual calculations.look forward to hearing you soon. { Duty_cycle_buck=90-(80*Buck_Ref_mv/3000); TIM_OCInitStructure.TIM_Pulse = (uint16_t) (((uint32_t) Duty_cycle_buck*(TimerPeriod - 1)) / 100);// duty cycle formula TIM_OC1Init(TIM1, &TIM_OCInitStructure);//OC1 selects PA8 }2014-07-11 07:30 AM
i have following conditions. the problem is that, my actual value & compiler value are not matching.
Yet you totally fail to convey enough detail that would let anyone do analysis! Here's a thought, specify what the Period value is for the timer, and what the Pulse value is. Understanding that Period is programmed with N-1 and Pulse with (Percent * N) / 100, and you must do the computation with enough bits of precision so as not to get invalid answers. What are the types, range and values of the other variables. 80 * 3000 won't fit in 16-bit2014-07-12 12:00 AM
TIM3->PSC = 23999; // Set prescaler to 24 000 (PSC + 1)
TIM3->ARR = 500; // Auto reload value 1000 (FOR 1 SECOND DELAY)TIM3->DIER = TIM_DIER_UIE; // Enable update interrupt (timer level)TIM3->CR1 = TIM_CR1_CEN;// Enable timerNVIC_EnableIRQ(TIM3_IRQn); // Enable interrupt from TIM3 (NVIC level)is any info are you looking for.my email id is deepak.chikane@gmail.comLook forward to hearing you soon.2014-07-12 04:26 AM
My calculation is not a ''80*3000'' its a 80/3000.
Yes, I know, and the reason I reversed the math is because there was no indication of range provided, so I picked a number I felt was reasonable. 80000 also doesn't fit either.2014-07-12 04:36 AM
Try
duty cycle=90-((8*buck_ref)/300) Which would work for 0-8191mV, compared to the prior version of 0-819.1mV if the math is done with 16-bit variables.