uint8_t sreg = SREG;
cli();
// critical region
SREG = sreg;
Just not AVR style registers:
http://infocenter.arm.com/help/index.js … BIBGJ.html
More here: http://docs.leaflabs.com/static.leaflab … ister-maps
I strongly suggest you download & read the official reference before you go off into the land of the registers. Unless you can articulate a precise question and submit sample code for STM, I doubt if anyone here will take too much time to assist you. There is just not enough time to walk through the architecture.
Good read: Discovering the STM32 Microcontroller – Computer Science Google for it.
Ray





you beat me to posting the gbrown update ! i’ve just put it up elsewhere
the second one, make sure you get the 850+ page version, it adds in the M4 and 400 odd pages. mine via Amazon
Greenwich_Books included the following items in package 1 of this shipment:
The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors
i’m not sure the price on the invoice was the same as on the product page, maybe £5 or £7 less
definitely new and substantially packaged, impressed.
stephen

my last group leader once tried to make me apologize for buying a book on something.
wrong move, i’ll never do that.
now if he’d said perhaps its wasn’t quite the right one, i might have agreed
stephen
class SREGemulation
{
public:
operator int () const __attribute__((always_inline)) {
uint32_t primask;
asm volatile("mrs %0, primask\n" : "=r" (primask)::);
if (primask) return 0;
return (1<<7);
}
inline SREGemulation & operator = (int val) __attribute__((always_inline)) {
if (val & (1<<7)) {
interrupts();
} else {
noInterrupts();
}
return *this;
}
};
extern SREGemulation SREG;
inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; }
#define sei() interrupts();
#define cli() noInterrupts();
Doesn’t matter the sensor principal.
void setup() {
pinMode(SpeedCountPin, INPUT_PULLUP); // interrupt count pin
attachInterrupt(digitalPinToInterrupt(SpeedCountPin), iCounter, RISING);
Timer3.setChannel1Mode(TIMER_OUTPUTCOMPARE);
Timer3.setPeriod(500000); // in microseconds
Timer3.setCompare1(1); // overflow might be small
Timer3.attachCompare1Interrupt(handler_led);
}
// motor speed counter interrupt
void iCounter(void){
mCount++;
}
void loop() {
[skip - not important]
}
// 0.5Hz timer for blinking and count the speed
void handler_led(void) {
toggle ^= 1;
digitalWrite(LED_PIN, toggle);
// calculate the speed
mSpeed = mCount*60*2/3; // count * 60 sec * 2 per sec / 3 segments on a wheel
mCount = 0;
}