kalman
Joined: 19 Jan 2010 Posts: 4
|
printf float doesn't work |
Posted: Mon Mar 08, 2010 9:13 pm |
|
|
Good day, I have got this printf problem when I try simulating with Proteus.
Using pcwhd 4.084
Code: |
#include <16f877a.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define INTS_PER_SECOND 60
long count;
#int_rtcc
void clock_isr() {
++count;
}
void main() {
long start,diff;
float dt;
set_timer0(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
do {
start=count;
getc();
diff=count-start;
dt=(diff)/60;
printf("%Ld %Ld %6.4f seconds.\n\r",count,start,dt);
} while (TRUE);
}
|
For example, start=0, count=133;
the value dt should be 2.2166, but it only shows 2.
Did I miss something there? |
|