[SOLVED] AVR SREG emulation
uint8_t sreg = SREG;
cli();
// critical region
SREG = sreg;
uint8_t sreg = SREG;
cli();
// critical region
SREG = sreg;Thu Jun 09, 2016 5:48 pm
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 STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog Microcontroller – Computer Science Google for it.
Ray
Fri Jun 10, 2016 9:44 am
Fri Jun 10, 2016 11:16 am
Fri Jun 10, 2016 11:25 am
Sat Jun 11, 2016 2:05 am
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-M3Cortex-M3Microcontrollers and processors…get this error arm-none-eabi-g++: error: unrecognized command line option '-CC -mcpu= cortex-m3 ' RogerClark Sun May 15, 2016 6:25 am Fixed it @vassilis do a pull from my repo to…View in hardware catalog and Cortex-M4Cortex-M4Microcontrollers and processors… the Due form factor) e.g. … 4de7935aae Mini-version-STM32F407VET6-development-board- Cortex-M4 -STM32-minimum-system-board.jpg Mini-version-STM32F407VET6-development-board-Cortex…View in hardware catalog 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
Sat Jun 11, 2016 2:28 am
Sat Jun 11, 2016 5:45 am
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
Sat Jun 11, 2016 2:41 pm
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();Sat Jun 11, 2016 9:04 pm
Sun Jun 12, 2016 3:57 am
Tue Jun 06, 2017 3:47 pm
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;
}