Hi Jerson,
I anticipate the actual switch involved being pressed very rapidly (think 'teen on an arcade button'!) ...I'd be worried about the overhead of getting in/out of any interrupt *after* trapping the switch being pressed, so I was thinking of an IOC interrupt for capturing the switch being pressed & then somehow trapping the next comparator toggle in the IOC interrupt routine.
At the minute the best I can come up with, is something along these (high level) lines...
Code:
Sw_Interrupt: 'IOC interrupt handler
'
stored_comparator_level = comparator_output_level ' store the present comparator logic level nb: I've not delved to get the actual registers involved, this is high level stuff!
'
while comparator_output_level = stored_comparator_level 'keep looping until there's a mismatch
wend
'
'ok, to drop out of above wend and get to this point, then there must be a mismatch (a zero cross - comparator toggle) so let's continue
'
PortA.1 = 1 ' switch PortA.1 high immediately after comparator has toggled (ie the control voltage to the audio switch)
...blah blah
Not even sure if you can use a while/wend like that?
PS Dave - you've lost me...this has nothing to do with AC mains?! (I'm talking low level audio zero cross detect)
Bookmarks