Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question for or1k_timer_set_mode in or1k-support.h #17

Open
minjiexm opened this issue Apr 18, 2018 · 2 comments
Open

Question for or1k_timer_set_mode in or1k-support.h #17

minjiexm opened this issue Apr 18, 2018 · 2 comments

Comments

@minjiexm
Copy link

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.
/*!

  • Set timer mode
  • The timer has different modes (see architecture manual). The default is to
  • automatically restart counting (SPR_TTMR_RT), others are single run
  • (SPR_TTMR_SR) and continuous run (SPR_TTMR_CR).
  • \param mode a valid mode (use definitions from spr-defs.h as it is important
  • that those are also at the correct position in the bit field!)
    */
    void or1k_timer_set_mode(uint32_t mode);

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

Please kindly help.

Thanks.

@wallento
Copy link
Member

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants