to get 250 ms count :
  • 1. change for displayloop = 0 to 28
    2. change for delay=1 to 313

simulation is really close to 250ms you need. Use Stopwatch in MPLAB to adjust it. place your breakpoint just before the Goto DisplayRefresh, place RunToCursor or SETPC at Display refresh.. that's it