Translating Atmega Registers into STM32F1 SOS!

Post here first, or if you can't find a relevant section!
Post Reply
gc9n
Posts: 5
Joined: Wed Jan 04, 2017 1:09 pm

Translating Atmega Registers into STM32F1 SOS!

Post by gc9n » Sat Sep 09, 2017 8:18 pm

Hello there
I have an old project on a Arduino Mega and i used those interupts bellow
can somebody please , help me translate it for STM32F1 i am having a hard time to understand what i have to do

Code: Select all

Initialize Amega registers
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input pin.
TCCR1B = _BV(CS10);
// Enable input interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC01);

i guess for a start i have to #include <libmaple/bitband.h>

zmemw16
Posts: 1417
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Translating Atmega Registers into STM32F1 SOS!

Post by zmemw16 » Sat Sep 09, 2017 8:45 pm

what it does is in the comments
immediate assignments are most likely set up values
look up the names in the atmegaxxxx datasheet & reference manual
look for equivalent in the stm32f1xxx datasheet & reference manual
search for how to use stm32f1 timers with google & on github
just as i'd do.
stephen

dannyf
Posts: 140
Joined: Wed May 11, 2016 4:29 pm

Re: Translating Atmega Registers into STM32F1 SOS!

Post by dannyf » Sat Sep 09, 2017 10:09 pm

fairly easy.

1) take out the datasheet, set / clear the bits for each of the registers and figure out what the module is doing. looks like it is enabling input capture interrupt 1 -> so take a look at the associated isr;

2) then go to your target chip and see how you would enable input capture interrupt and code the isr in a similar fashion.

Post Reply