The following code does not yield the answer I expect when I multiple a float * 12.
void setup_timer_parameters(float micro_seconds)
{
//constants
calibration = 0;
//calculables
periods_needed = micro_seconds * 12 + calibration;
target_overflows = periods_needed / 65536;
overflows_counter = target_overflows;
temp = periods_needed - (target_overflows * 65536);
leftover = (long)temp;
//int overflows_needed = micro_seconds % timer_period;
printf(lcd_putc, "\fPN%05f TMP%05f\nTO%05f LO%05f", periods_needed, temp, target_overflows, leftover);
}
void main(){
setup_timer_parameters(20000F);
}
For some reason my display shows me that periods_needed is -518! Why isn't it 20000*12 = 240000?