Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

cyg_thread_delay

Altera_Forum
Honored Contributor II
1,269 Views

Hi, I am new to eCos.  

Currently I am using CycloneII chip with 40Mhz clock. 

 

I would like to delay for 1 second. 

I read eCos documents. And I found that I'm supposed to use below method. 

 

cyg_thread_delay(DELAY); 

 

But I'm not sure what value do I have to put in 'DELAY'. 

 

A clock that runs at 40MHz.  

In order to delay 1 second, which is 1000 millisecond, how to work out the number of clock ticks? I got confussed while I am reading the documents. 

Could you help me out, here?  

 

(I was doing experiments by putting random in DELAY, and it seems that  

cyg_thread_delay(1000);  

seems to be 1 second approximately. But I would like to know how to calculate it.) 

 

Thanks in advance.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
395 Views

Hi romiodelta, 

 

> But I would like to know how to calculate it.) 

 

from the ecos reference manual: <div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

If the application requires delays measured in milliseconds or similar units rather than in clock ticks, some calculations are needed to convert between these units as described in Clocks. Usually these calculations can be done by the application developer, or at compile-time. Performing such calculations prior to every call to cyg_thread_delay adds unnecessary overhead to the system.[/b] 

--- Quote End ---  

 

 

See "Delay" at: http://ecos.sourceware.org/docs-latest/ref...ad-control.html (http://ecos.sourceware.org/docs-latest/ref/kernel-thread-control.html

Also Clock Resolutions and Ticks" and "cyg_clock_get_resolution" at: 

http://ecos.sourceware.org/docs-latest/ref...nel-clocks.html (http://ecos.sourceware.org/docs-latest/ref/kernel-clocks.html

 

Regards, 

--Scott
0 Kudos
Reply