openrisc / newlib

newlib OpenRISC development
GNU General Public License v2.0
24 stars 24 forks source link

Question for or1k_timer_set_mode in or1k-support.h #17

Open minjiexm opened 6 years ago

minjiexm commented 6 years ago

hi, Dear expert:

I follow the steps in https://openrisc.io/newlib/building.html to build my own or1k toolchains. Now I am trying to use timerrelated functions in $OR1K_ELF/or1k-elf/include/or1k-support.h.

I first start with the example at line 446 in or1k-support.h

void tick_handler(void) { // Make schedule decision // and set new thread or1k_timer_reset(); // End of exception, new thread will run } int main() { // Configure operating system and start threads.. // Configure timer or1k_timer_init(50); or1k_timer_set_handler(&tick_handler); or1k_timer_set_mode(SPR_TTMR_SR); or1k_timer_enable(); // Schedule first thread and die.. }

But the example failed to pass compile because the define SPR_TTMR_SR is missed. I try to get the answer from the define of or1k_timer_set_mode. /*!

But I still not clear about the value of mode for simple run and continues run.

Please kindly help.

Thanks.

wallento commented 6 years ago

Hi,

it is defined in or1k-sprs.h. Please include that one.

I will soon update the documentation or the source code accordingly.

Cheers, Stefan

minjiexm commented 6 years ago

hi, wallento:

Thanks for point out.

I find below 3 defines in or1k-sprs.h.

/ Restart counting when TTMR[TP]==TTCR /

define OR1K_SPR_TICK_TTMR_MODE_RESTART 1

/ Stop counting when TTMR[TP]==TTCR /

define OR1K_SPR_TICK_TTMR_MODE_STOP 2

/ Continue counting when TTMR[TP]==TTCR /

define OR1K_SPR_TICK_TTMR_MODE_CONTINUE 3

My understanding is: or1k_timer_set_mode(OR1K_SPR_TICK_TTMR_MODE_CONTINUE) is or1k_timer_set_mode(SPR_TTMR_CR) in the doc. or1k_timer_set_mode(OR1K_SPR_TICK_TTMR_MODE_STOP) is or1k_timer_set_mode(SPR_TTMR_SR) in the doc.

What does OR1K_SPR_TICK_TTMR_MODE_RESTART means?

Thanks.