5
When I turn off the timer overflow interruption from PWM
(+- 15Khz) operations occur normally. But when it is turned on the processor gets lost in floating point operations. I follow by the debug in step mode but at some point the debug does not return and is as if running only giving another pause that always falls in the described interruption.
I’m wearing a K20
without Freescale’s FPU and I asked around in the community but they didn’t even call.
I’ve increased the stack, but no improvement.
I had the same problem with a S08PA
, but this was only to lower the occurrence of overflow timer (from 20Khz to 15Khz) that worked correctly.
Edit:
Not really a firmware as I am caught in this problem. Only there is the interruption of the PWM
and the routine to generate the Sine table.
// Gerador da tabela
void PWMInit(){
float a;
int i,r;
// Combine mode Pulse = CN+1 - CN
// Complementary mode : N+1 = Inv(N)
Motor.DutyMax = FTM0_MOD - FTM0_CNTIN;
Motor.DutyZero = Motor.DutyMax >> 1;
Motor.Frequencia = 60;
Motor.MaxSamples = PWMFreq / Motor.Frequencia;
Motor.VMod = (Motor.DutyMax / 60) * Motor.Frequencia;
Motor.IncTabela = (float) 1000.0f / Motor.MaxSamples;
Motor.Div = (((long) MAXTABELA / Motor.VMod));
/*
for (i=0, a=0; i < Motor.MaxSamples; i++, a += Motor.IncTabela ) {
r = SinT[(int)(a + 0.5f)];
r = r / Motor.Div;
r = Motor.DutyZero + r;
TabelaGerada[i] = (uint16_t) r;
}
*/
float ri = (2*PI) / Motor.MaxSamples;
float rr = 0;
for (i=0; i < Motor.MaxSamples; i++) {
TabelaGerada[i] = Motor.DutyZero * ((float) 1.0f + sin(rr));
rr = rr + ri;
}
SetW(100);
SetV(500);
SetU(900);
FTM0_SYNC |= (FTM_SYNC_SWSYNC_MASK | (1 << 7));
}
// Interrupção
PE_ISR(EstouroDoTimerFTM0){
(void)(FTM0_SC == 0U);
Counter = 0;
}
Could post firmware code?
– Avelino
I haven’t programmed for microcontrollers in a long time, but the default hardware interruptions I didn’t use I put an IRET instruction. I don’t know if it’s your case.
– lsalamon
Using C I don’t need this ASM instruction.
– user1084
Your case seems to be even too many interruptions, since by decreasing the frequency you say it works. If you need a very high interrupt rate the processor should be able to perform the other tasks and in case calculations require many cycles. This is why you can get lost in debugging.
– lsalamon
I decrease the time of occurrences to something around 1ms (compared to 50uS), but nothing to improve.
– user1084
Fábio, I recommend the divide technique to conquer. Try to mount your code only a floating point operation and leave your timer on the 50uS frequency and see if it works properly with debugging. Thus you eliminate the load factor as the source of your problems. The next step will depend on the result.
– lsalamon