??? 01/11/05 15:13 Read: times |
#84760 - code Responding to: ???'s previous message |
this is the interrupt service routine
external0() interrupt 0 /* Routine runs when external echo is received */ { TR0=0; /* Turn off timer0 */ EX0=0; /* Turn off external interrupt */ ECHO=1; /* Set Pin3^2 external interrupt back high */ timehi=TH0; /* copy value of TH0 to timehi */ timelo=TL0; /* copy value of TL0 to timelo */ totcount = timehi; /* Calculations for displaying distance in cm */ totcount = totcount * 256 + timelo; time = totcount; time = time * clk; /* calculates the time of the count */ dist = time / factor; /* This is a floating point number so accuracy */ /* will be lost - i.e. only the real part given */ init_serial(); /* Run Serial initialisation to send dist value */ for(;;) { if(timehi!=0xFF) printf("dist %u cm time %lu totcount %un ", dist, time, totcount); break; } TI=0; init_serial(); for(;;) { if(timehi==0xFF) printf("no obstaclen"); break; } TI=0; init_timer(); /* >>RESTART<< Run initialise timer function */ } where: printf("dist %u cm time %lu totcount %un ", dist, time, totcount); now works ok. |
Topic | Author | Date |
Multiplication Problems and data types | 01/01/70 00:00 | |
use unsigned int for totcount | 01/01/70 00:00 | |
Wrong printf format specifier? | 01/01/70 00:00 | |
yes i am using printf | 01/01/70 00:00 | |
manual! | 01/01/70 00:00 | |
using %d and %x | 01/01/70 00:00 | |
%u | 01/01/70 00:00 | |
Exactly what it says on the tin! | 01/01/70 00:00 | |
Division problem? | 01/01/70 00:00 | |
division problem in keil evaluation? | 01/01/70 00:00 | |
Which Part? | 01/01/70 00:00 | |
its ok i have sorted it! | 01/01/70 00:00 | |
Still a problem, then... | 01/01/70 00:00 | |
not so strange | 01/01/70 00:00 | |
Not so strange? | 01/01/70 00:00 | |
Need complete code! | 01/01/70 00:00 | |
Like this | 01/01/70 00:00 | |
code | 01/01/70 00:00 | |
Calling printf from an ISR | 01/01/70 00:00 | |
other interrupts wont get in the way | 01/01/70 00:00 | |
ISR | 01/01/70 00:00 | |
yes i see what you mean | 01/01/70 00:00 | |
No No Inside ISR![]() | 01/01/70 00:00 |