Part of this project is obviously timing.
Say I have a pulse coming in at between 50 and 200uS and I need to match this incoming pulse to an output. Not really a problem.
IF PORTA.0 = 1 THEN PORTA.1 = 1
But what if that incoming pulse is longer than the 200uS and the output must be shut off after a predetermined maximum, lets say 1000uS?
IF PORTA.0 = 1 THEN PORTA.1 = 1 no longer works. TMR0 has to be triggered at the same time as PORTA.1 goes high, then needs to count to a maximum of 1000uS and make PORTA.1 = 0.
PORTA.1 then must be kept low until PORTA.0 has gone low.
When PORTA.0 = 0 TMR0's flag can be reset and wait for PORTA.0 to go high again. If PORTA.0 has gone low before TMR0 has set the flag, it must be reset and ready to count to 1000uS.
Does this make sense?




Bookmarks