how to do mdelay on M4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to do mdelay on M4

423 Views
run_zhao
Contributor I

Hi,NXP Expert,

    l can not find mdelay function In sample code for i.MX8M Mini 's M4, if we need delay 1ms ,how to implement it ?

as below

void mDelay(iTE_u16 Delay_Count)
{
   uint32_t i;
   while(Delay_Count--)
       {
              for (i = 0; i < 1000; i++) {
                __NOP();
              }
       }
}

but l am not sure how many __NOP() use ? how to compute it ?

thanks

Labels (1)
0 Kudos
1 Reply

371 Views
b36401
NXP Employee
NXP Employee

Actually it depends on the compiler how it to realize this loop.
I can suggest to set some amount of NOPs measure the delay and then correct it.

0 Kudos