mop
December 15th, 2002, 11:14 AM
At a loss on an ideal implementation approach as it relates to an interrupt handler. Information outlined in RequestBit is what I'd like to implement.
Some background info. RequestBit (the very first time) will be called from within a 20 hertz processing routine. I'll then 'ignore' 20 Hz calls via a flag that I'll set inside the 20Hz routine and in turn send a bit command, wait 2ms for the device to respond with the interrupt then continue to send bit commands via synchorize with the interrupt. if the interrupt does not happen within the 2 ms. .... see below for more.
if some could point me in the right direction, i'd appreaciate it. Pseudo code will work. Thanks in advance.
// so now. RequestBit gets called ONCE the very first time from the 20 Hz routine
void RequestBit()
{
CMDWORD.CmdData.Ocw2_Device_Mode = 1; // Bit
RequestData((_CMDWORD_UNION*)CMDWORD.CMDWORD_ARRAY,
&OCMDWORDSTATUS); // Send Bit Command
1. Send bit command per above
2. Wait 2 ms for the device to send the interrupt.
3. If no interrupt within the 2 ms, send the bit command again, then wait 2ms. If yet again no interrupt within the 2 ms, then give up. Send Standby command
4. On the other hand, if interrupt happened within the 2ms. The interrupt routine (below) will be called, which in turn calls RequestBit. Simply put, synchronize with the interrupt and send bit commands. If after sometime we’ve been synchronizing and suddenly ‘lost’ the interrupt. Give up. I.e. Send Standby command. Ensure that ‘any’ spurious interrupt that happens after we send the standby command gets ignored.
}
interrupt Interrupt_0(void)
{
RequestBit();
}
void RequestStandby()
{
CMDWORD.CmdData.Ocw2_Device_Mode = 0; // Standby
RequestData((_CMDWORD_UNION*)CMDWORD.CMDWORD_ARRAY,
&OCMDWORDSTATUS); // Send
Sby
}
Some background info. RequestBit (the very first time) will be called from within a 20 hertz processing routine. I'll then 'ignore' 20 Hz calls via a flag that I'll set inside the 20Hz routine and in turn send a bit command, wait 2ms for the device to respond with the interrupt then continue to send bit commands via synchorize with the interrupt. if the interrupt does not happen within the 2 ms. .... see below for more.
if some could point me in the right direction, i'd appreaciate it. Pseudo code will work. Thanks in advance.
// so now. RequestBit gets called ONCE the very first time from the 20 Hz routine
void RequestBit()
{
CMDWORD.CmdData.Ocw2_Device_Mode = 1; // Bit
RequestData((_CMDWORD_UNION*)CMDWORD.CMDWORD_ARRAY,
&OCMDWORDSTATUS); // Send Bit Command
1. Send bit command per above
2. Wait 2 ms for the device to send the interrupt.
3. If no interrupt within the 2 ms, send the bit command again, then wait 2ms. If yet again no interrupt within the 2 ms, then give up. Send Standby command
4. On the other hand, if interrupt happened within the 2ms. The interrupt routine (below) will be called, which in turn calls RequestBit. Simply put, synchronize with the interrupt and send bit commands. If after sometime we’ve been synchronizing and suddenly ‘lost’ the interrupt. Give up. I.e. Send Standby command. Ensure that ‘any’ spurious interrupt that happens after we send the standby command gets ignored.
}
interrupt Interrupt_0(void)
{
RequestBit();
}
void RequestStandby()
{
CMDWORD.CmdData.Ocw2_Device_Mode = 0; // Standby
RequestData((_CMDWORD_UNION*)CMDWORD.CMDWORD_ARRAY,
&OCMDWORDSTATUS); // Send
Sby
}