??? 07/07/06 13:04 Read: times |
#119805 - the entire problem again Responding to: ???'s previous message |
the code to be able to calculate the frequency of external pulse at P3_2 is as below:
bit flag = 0; unsigned int timercounts = 0; float time = 0.0; unsigned int rpm = 0; void main(void){   TMOD = 0x09;   //sets timer0 in 16-bit mode   //timer0 will run only when INT0(3.2) is high   TH0 = 0;   TL0 = 0;   TR0 = 0;   IPL0 = 0x01;  //highest priority to external interrupt 0   IPH0 = 0x01;   IEN0 = 0x81;    //enabling external interrupt   while(1); } void externalinterrupt(void) interrupt 0    //invoked on every positive edge {    if(!flag){    TR0 = 1;    //enable timer0    flag = !flag;   }    if(flag){    TR0 = 0;   //disable timer0    IEN0 = 0x00;    //disable all interrupts    flag = !flag;    timercounts = (TH0*256) + TL0;    time = timercounts/921583;    rpm = (unsigned int)(30/time);    } } however the output is quite bizzare as it shows a constant no. even if the input pulse is changed....pls suggest where i may have gone wrong |
Topic | Author | Date |
frequency of a digital pulse | 01/01/70 00:00 | |
Variable definitions ? | 01/01/70 00:00 | |
Please post formatted code | 01/01/70 00:00 | |
Some points: | 01/01/70 00:00 | |
misconceptions cleared | 01/01/70 00:00 | |
inappropiate response | 01/01/70 00:00 | |
the entire problem again | 01/01/70 00:00 | |
flag=!flag ? | 01/01/70 00:00 | |
The value of Flag is known! | 01/01/70 00:00 | |
I see, but I don't C | 01/01/70 00:00 | |
It's illogical, Captain... | 01/01/70 00:00 | |
It is worse than that![]() | 01/01/70 00:00 | |
nope | 01/01/70 00:00 | |
Please post formatted code!! | 01/01/70 00:00 | |
he did follow the instructions | 01/01/70 00:00 | |
Oh no he didn't! | 01/01/70 00:00 | |
Argument | 01/01/70 00:00 | |
well, I saw the indentions and - shame | 01/01/70 00:00 | |
formatted code................. | 01/01/70 00:00 | |
thus therefore undefined | 01/01/70 00:00 | |
Formatted, but not the same code! | 01/01/70 00:00 | |
2 problems off the top | 01/01/70 00:00 | |
a blatant understatement | 01/01/70 00:00 | |
Implicit casting mess. | 01/01/70 00:00 | |
commentless code is worthless | 01/01/70 00:00 |