Abstract
Since the CPU speed is too fast, many people cannot see the result at all. Therefore, how can we find C in the case of niosii if we want to stop running for n seconds and then try again?
Introduction
Environment: US us II 7.2 SP3 + niosii eds 7.2 SP3 + de2 (Cyclone II ep2c35f627c6)
This example uses(Formerly known) de2_nios_lite 1.1 (SOC) (nano II) (Systems builder) (μC/OS-II) (de2)For example
The usleep () function is provided in unistd. H. You can stop running n micro-seconds. To stop running for n seconds, it is equivalent to usleep (N * 1000*1000 );
Hello_world.c/C
/*
(C) oomusou 2008 Http://oomusou.cnblogs.com
Filename: hello_world.c
Compiler: Quartus II 7.2 SP3 + NiO II eds 7.2 SP3
Description: Demo how to use usleep ()
Release: 08/29/2008 1.0
*/
# Include<Stdio. h>
# Include"Unistd. h"
int main () {
while ( 1 ) {
printf ( " hello from NiO II! \ N " );
usleep ( 1 * 1000 * 1000 );
}
Return 0;
}
Results
(The "hello from niosii!" statement is displayed every second !)
Hello from NiO II!
Hello from NiO II!
Hello from NiO II!
Hello from NiO II!
Hello from NiO II!
Hello from NiO II!
Download the complete program
De2_nios_usleep.7z
See also
(Formerly known) de2_nios_lite 1.1 (SOC) (nano II) (Systems builder) (μC/OS-II) (de2)