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

[stm32f4-discovery] Added timer example for the stm32f4 discovery board. #79

Merged
merged 2 commits into from Feb 14, 2015

Conversation

esden
Copy link
Member

@esden esden commented Feb 12, 2015

This example exposes an interesting difference between f1 and f4. The clocks for the timers are not exactly the same ones as for other peripherals.

Oh JOY! :)

@flixr
Copy link
Member

flixr commented Feb 12, 2015

Yeah, that is why I wrote the timer_get_frequency function: libopencm3/libopencm3#286.
The updated version currently used in Paparazzi: https://github.com/paparazzi/paparazzi/blob/v5.4/sw/airborne/arch/stm32/mcu_arch.c#L127

But this is basically the same for F1!

tim_setup();

while (1)
__asm("nop");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__WIF(); would be cool instead maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean __WFI();? I did not know about this assembly call. Good to know. Thanks for pointing it out. I will use that. For those reading this. To save you time searching what this is. It stands for "Wait For Interrupt" and is a hint instruction that suspends execution until one of the following events occurs:

  • a non-masked interrupt occurs and is taken
  • an interrupt masked by PRIMASK becomes pending
  • a Debug Entry request

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/BABFEFIG.html

@esden
Copy link
Member Author

esden commented Feb 13, 2015

@flixr OK that is really embarrassing that I did not know that it was the same case for the stm32f1 too. You have just blown my mind here. 😊

I think the right way of dealing with that would be to update the way rcc is being set on the f1 to be in the style of f4 and pull that information from the setup struct. I will explain what I mean in a separate pull request, with the proposed changes.

For now I think this patch should be ok until we have something in the style of what you proposed or a variation on that in place...

WFI (Wait for Interrupt) tells the processor to suspend untill the next
interrupt is called. Better than burning away the cycles with nop.
@esden esden merged commit 4de8d15 into libopencm3:master Feb 14, 2015
@esden esden deleted the stm32f4-timer branch February 14, 2015 00:43
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

Successfully merging this pull request may close these issues.

None yet

3 participants