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++

uCos not setting timers

Altera_Forum
Honored Contributor II
1,150 Views

uCos does not appear to explicitly set the HW timer period for its interval timer.  

If a boot loader changes the default timer settings for this timer,  

when uCos boots it will assume the default period is used, when it is not. 

Have not tracked down where the problem is.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
527 Views

The uCos port assumes that the timer is set to the period you selected in SOPC Builder, which is the value that is reflected in system.h. We cannot guarantee that the hardware has a writeable period register. None of the software which runs before MicroC/OS-II alters the period. If your bootloader is modifying the period, it should change the timer period back before loading MicroC/OS-II.

0 Kudos
Altera_Forum
Honored Contributor II
527 Views

Simple enough. 

But isn't the uCos init code assuming both that the timer is set correctly AND that it is set to the default?  

I was thinking these assumptions could easily be checked, or that always explicitly writing to the desired (default) value  

to the period registers would be OK, whether or not they really exist. With SOPC, the register space for the  

timers has the same size regardless of options, so there is no risk of accessing the wrong register. This might  

not be true for different HW, but init is expected to be custom anyway.  

 

I don't think you would ever want a uCos app to run at timer interval different from what it thinks it is. Robustness?
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

But isn&#39;t the uCos init code assuming both that the timer is set correctly AND that it is set to the default?  

I was thinking these assumptions could easily be checked, or that always explicitly writing to the desired (default) value  

to the period registers would be OK, whether or not they really exist.[/b] 

--- Quote End ---  

 

 

Yes the uCos code is assuming that the timer is set to the default, because none of the code running before it modifies it. With embedded systems it&#39;s always a trade off of functionality and error checking against code size. Yes we could add code to check it, but we would be adding code to check for something which should not happen unless some other code has run before uCos.
0 Kudos
Reply