How can I delay for 1 microsec on my F2808? I need a 1 microsec pulse on a GPIO out.

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Submitted by Joe on Tue, 03/22/2011 - 20:35 

 

I need a 1 microsec output pulse on a GPIO out pin. I will need to set the pin low, delay 1 microsec, then set it high. I know there is a NOP instruction which takes 1 tick. How to I use that?

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2020

    Submitted by Anders89 on Tue, 03/22/2011 - 20:43.

     

    You can use the externFunction block to create a small delay loop by putting the following C loop into it:

       { int a; for (a=0;a<10;a++) asm('NOP');} 

    Note that though the chip clock is 100 MHz, the loop count is only to 10. That is because one loop iteration takes 10 ticks due to an 8 tick pipeline stall + 1 tick NOP + 1 tick inc/compare loop counter.
    Then write a 0 to the GPIO above the NOP delay, and write a 1 to the GPIO below it. VisSim generates code for parallel flows in top down order, so you will get a 1 microsec low pulse.

    See attached diagram below (you must be logged in to see it).

    Unable to find an attachment - read this blog