(Reporter) How do I stop waiting for n seconds before renewal? (SOC) (de2) (nio ii)

Source: Internet
Author: User
Tags usleep

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.