Ok, I've managed to pinpoint the issue.
I'm using pwm at 16bit resolution.
This error message was originated because negative values were being passed to the PWM OCx registers.
The problem seems to be the built in map function.
I'm passing to it unsigned long variables, but it doesn't see them that way. It seems that they are being interpreted has signed shorts because when 32767 is reached, after that the values become negative.
The function was this:
lv_mapedpwm=map(PWMout,0UL,65535UL,MinPWM,MaxPWM);
MinPWM and MaxPWM are declared has unsigned long also.
This yeld negative values in lv_mapedpwm var.
I've then used one map function for floats and worked like a charm, although values being passed has UL.
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
the odd thing is that the compiler doesn't complain at all when I pass the UL values to the map function.
Isn't this an issue with IDE itself? I'm using 1.5.3 version at the moment.
waiting for your comments.