I was using P2020rdb board . I have written program to monitor ptp timer event register for input trigger pulse. 1PPS input is given to that board and whenever rising edge comes an event is generated in timer event register. the event is monitored and GPIO is made high based on that input pulse for 20 microseconds. But i have getting a variable delay of 4 micorsecond to 6 microseconds in it. even after changing scheduler to RR or FIFO the delay remains the same. Could someone help in reducing that delay , please find below the code snapshot
extts_reg_l = *TMR_ETTS1_L;
while (1) {
if(((extts_reg_l - *TMR_ETTS1_L) != 0) )
{
*GPIO_DAT_REG |= 0x200000;
//1830 = 20 usec
for(i=0;i<(1830);i++)
{
;
}
extts_Reg64 = (UINT64) *TMR_ETTS1_H;
extts_Reg64 = (uint64_t)(extts_Reg64 << 32);
tmp_reg = *TMR_ETTS1_L;
extts_Reg64 |= (UINT64) tmp_reg;
extts_ts = (uint64_t)extts_Reg64;
//extts_offset = extts_ts % (NS_PER_SEC);
extts_offset = extts_ts % (NS_PER_SEC);
if (extts_offset > NS_PER_SEC / 2 )
extts_offset -= (NS_PER_SEC);
extts_reg_l = *TMR_ETTS1_L;
*GPIO_DAT_REG &= 0xFFDFFFFF;//low
//if(servo_active)
//{
do_servo(&servo, FD_TO_CLOCKID(phc_fd), extts_offset, extts_ts, kp, ki);
//}
//show_servo(stdout, "extts", extts_offset, extts_ts);
}