Skip to content

Question for or1k_timer_set_mode in or1k-support.h #17

@minjiexm

Description

@minjiexm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions