I'm developing an application on an ICEv2 board using SYS/BIOS Industrial SDK v2.01.03.02 that has to timestamp rising an falling edges of some signals routed to latch0/1 inputs.
The application works almost perfectly, that meaning that I'm able to properly get the timestamps, but the after the first PDI interrupt due to a latch, bit 1 of register 0x220 is never reset.
Because of that the application gets flodded by pdi interrupts.
In pseudo code this is what it does.
the Beckhoff slavestack has been modifed to notify the latch events to the application:
void PDI_Isr(void)
{
...
UINT16 ALEvent = HW_GetALEventRegister_Isr();
...
if ( ALEvent & LATCH_EVENT ) /* LATCH_EVENT = 0x02*/
{
APPL_Latch();
}
...
}
Uint16 APPL_StartInputHandler(Uint16 *pIntMask)
{
bsp_write_word( pruIcss1Handle, 0x0303, 0x09A8 );
bsp_pdi_latch0_control(pruIcss1Handle, 0x03);
bsp_pdi_latch1_control(pruIcss1Handle, 0x03);
*pIntMask |= 0x0002 ;
return ALSTATUSCODE_NOERROR;
}
void APPL_Latch()
{
Uint8 latchreg = bsp_read_byte( pruIcss1Handle, 0x09AE);
if( latchreg & 0x01 )
{
/* Latch 0 positive edge */
bsp_get_latch0_posedge_time(pruIcss1Handle, (Uint32*)(&sSynchronisationFsm.latch0PositiveEdge), (Uint32*)(&sSynchronisationFsm.latch0PositiveEdge)+1);
}
if( latchreg & 0x0002 )
{
/* Latch 0 negative edge */
bsp_get_latch0_negedge_time(pruIcss1Handle, (Uint32*)(&sSynchronisationFsm.latch0NegativeEdge), (Uint32*)(&sSynchronisationFsm.latch0NegativeEdge)+1);
}
latchreg = bsp_read_byte( pruIcss1Handle, 0x09AF);
if( latchreg & 0x01 )
{
/* Latch 1 positive edge */
bsp_get_latch1_posedge_time(pruIcss1Handle, (Uint32*)(&sSynchronisationFsm.latch1PositiveEdge), (Uint32*)(&sSynchronisationFsm.latch1PositiveEdge)+1);
}
if( latchreg & 0x02 )
{
/* Latch 2 negative edge */
bsp_get_latch1_negedge_time(pruIcss1Handle, (Uint32*)(&sSynchronisationFsm.latch1NegativeEdge), (Uint32*)(&sSynchronisationFsm.latch1NegativeEdge)+1);
}
}
I verified that after having read the latch timestamp registers, the corresponding bits in latch status registers are correctly reset (0x9AE[1:0] = 0, 0x9AF[1:0] = 0), but the bit 1 of the AL Event register is still set (0x220[1]=1).
Based on Beckhoff ESC documentation this should not happen (see attached image).
So my question is: am I missing something?
Is there any esc bsp api call that I should add to reset it?
Or is there something to be fixed in the pru firmware?
Thanks for your help.
Paolo Mastrapasqua