Hello all,
I hope someone can help me as I am tackling my first ever work projec with 8051 and my previous experience is .....absolutely nothing, zero.
I need to poll a pin for 5 seconds, and take certain actions when i changes from high to low, but then go back to polling. Interrupts don' seem like an ideal solution since it will interfere with the pollin process. How should I go about doing this? I read up on how to use th clock frequency (24MHz for the Cypress EZ-USB NX2LP) to calculate how lon a machine cycles takes, and then I could use that to determine how man cycles equate to 5 seconds but how would I account for the delay whe processing the "if pin is low" condition?
Rough Pseudocode :
For 5 seconds { while (port pin is high) track machine cycle count to make sure 5 secs has not passed. set a flag to indicate Pin has gone low continue checking Port Pin }
I don't think using a "time-delay" routine would work as I need t continuously poll the pin. Is that accurate? What about using a time without invoking an interrupt?
Oh, I am using C for this project. I hope I was able to convey m questions adequately.
Thanks in advance for any help.