Hello,
I am using ADUC842.
Continuous pulse is being fed at port P2.6
I need to calculate rising edges of the pulse for 10ms time interval..
how should i proceed?
pls help.
Regards Mayuri
how should i proceed? 1) put an inverter between the unit that generates the edge and the uC pin. 2) analyze the problem 3) read the datasheet 4) write a simple first code that turns on a LED on an edge 5) write the final code 6) test it 7) deliver it
This will be a hardware change.
Can you suggest me a solution wherein there is no hardware change.
Change should be respect to the code.
Can you suggest me a solution wherein there is no hardware change. '51 interupts can only be configured for falling edge.
Erik
can't you do the same with falling edges
Now the scenario is different..
I have continuous train of pulses wherein pulse of 14 ms duration is always repetitive..
Its like if there are X number of highs in 14ms repetitive duration then the module is detected if not den it is not detected.. so now i need to count number of highs.....
Here is the code i have written
TMOD = 0x10;//CONFIGURING 14 ms TIMER TH1 = 0xFA;//CONFIGURING 14 ms TIMER
TL1 = 0x89;//CONFIGURING 14 ms TIMER
while (1) //IN CONTINUOUS LOOP { do { TR = 1; //START TIMER if (P1 == 1) //checking for high { count++; //if there is a high den increase the count } if(count == 5) //checking for count { display(); //module is detected and hence display } while (TF1 == 0); TR1 = 0;//stop timer TF1 = 0;
}
Is this logic fine?
Your logic don't even seem to agree with your english text.
You say a pulse is 14ms "pulse of 14 ms duration is always repetitive". But then you seem to want to write code that counts number of pulses within a single 14ms period.
Was it hurtful to follow the instructions how to post source code?
Your loop don't contain any clear of a variable so your count value will just go up and up and up and up - what logic is that?
Checking if a signal is high isn't the same as knowing there have been a pulse.
Next thing - high or low flank doesn't matter. Any sequence of many pulses must still have multiple flanks of each type. Why don't you want to let the hardware count flanks?
"Is this logic fine?" What does the debugger tell you?
pulse of 14 ms is repetitive means i m getting continuous signal of 14ms duration which has a unique pattern...
I am planning to use ISR...
Sorry - you are still not clear.
On one hand, you talk about "pulse" (that seems to be 14ms long). Then you talk about "continuous signal". Then you say these 14ms have a "unique pattern".
So you have a single pulse 14ms long? Or a time window of 14ms with either zero or one pulse? Or a time window of 14ms with zero or many short pulses? Or either "silence" or a continuous sequence of 14ms long pulses? Or something else???
Slow down, and write enough text that we can understand you. Or graph it. Below would be an example of an "unique pattern" within a 14ms window:
+--+ +--+ +--+ +--+ | | | | | | | | -+ +--+ +--------+ +--+ +------------------- |---------- 14 ms----------|
ya r8..this is the pattern i m getting...this pattern is repeting again and again
TMOD = 0x05; // TIMER 0 , MODE 1 SELECTED TL0 = 0x89; // 14 ms timer TH0 = 0xFA; // 14 ms timer
while(1) { do { TR0 = 1;
P1 = TLO;//reading the count in port } while(TF0 == 0); TR0 = 0; TF0 = 0; } } I am using timer as counter for counting pulses.... Is this logic fine?
I guess you just refuses to read up on how to post source code on this forum.
So we better refuse to read what you post too.
Didn't you notice the different look in my post?
#include <stdio.h> void main(void) { printf("Hello world!\n"); for (;;) ; }
And by the way - why don't you test your code instead of asking "is this logic fine"? Code having so few lines really do not take too long to test. You just can't develop applications without debugging.
View all questions in Keil forum