I was looking at some Arduino code that uses timer interrupts and was wondering if there was an equivalent using the MF. There are something like 8 timers on the STM32F205RF. The Arduinoo code looks like this:
void init_interrupts(void)
{
/* First disable the timer overflow interrupt while we're configuring */
TIMSK1 &= ~(1<<TOIE1);
/* Configure timer2 in normal mode (pure counting, no PWM etc.) */
TCCR1A &= ~((1<<WGM11) | (1<<WGM10));
TCCR1B &= ~((1<<WGM13) | (1<<WGM12));
/* Disable Compare Match A interrupt enable (only want overflow) */
TIMSK1 &= ~(1<<OCIE1A);
// Prescalar = 8. Time between interrupts ~=32ms;
TCCR1B &= ~(1<<CS12); // Clear bit
TCCR1B |= (1<<CS11); // Set bit
TCCR1B &= ~(1<<CS10); // Clear bit
/* Finally load and enable the timer */
TCNT1 = tcnt1;
TIMSK1 |= (1<<TOIE1);
}
I suppose one would have write custom firmware to get at timer registers.
REF:
http://www.protostac...n-an-atmega168/
Timer Interrupts
Started by sfugarino, Mar 15 2014 04:42 AM
3 replies to this topic
#1
Posted 15 March 2014 - 04:42 AM
#2
Posted 15 March 2014 - 06:44 AM
Depends upon the accuracy you are after. NETMF has timers built in to the framework. Have a look at this article if you are interested in finding out more.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#3
Posted 15 March 2014 - 05:48 PM
Exactly what I was looking for, thanks.
#4
Posted 22 March 2014 - 08:04 AM
I found some code for the Cerberous boards that, I guess, uses custom firmware. Would tiis code work for Netduino? Also how about adding a HAL in the future that would give similar access to the controller's register. Arduino has this, chipKit does, and apparently GHI does or can. See the attached file.
Attached Files
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users