New answers tagged

0

I do that all the time but I also read the data sheet. There is a limit on the amount of current you can inject into a processor pin or in total, that is on the data sheet. Also be aware when you inject current you can cause VCC to go out of specification unless it has enough load to support it. Typically I limit my input current to less than 1mA with a ...


3

The Atmega328p (which is used in the Un[ (and actually all other AVR microcontrollers) has clamping diodes in the input hardware to protect it from overvoltage (above Vcc). When not powered, Vcc is at the same level as ground, so any positive voltage on an input pin is above Vcc. The protection diodes get conductive to protect the input hardware. Note, that ...


1

Code Correction 7th October - Tidy code as per comments Code Correction 7th October - proper reading of rotary encoder Uses the Pin Change interrupts to allow increment and decrement of the 2 rotary encoders within an interrupt service routine using arduino (in my case nano) with ATMEGA328P chip. Need to add 2 x 104 (0.1uF caps) at the rotary encoder between ...


1

It is possible to use the Timer0 compare interrupts without affecting the millis() and micros() functions. Simply set the compare interrupts to occur at 1/3rd and 2/3rds of the overflow period. That way they won't conflict with each other because there will be some time between each of the three interrupts (overflow, compare A and compare B). You can't ...


1

As you already found, the function to override is __irq_adc() defined weakly here and bound to the interrupt vector table here. If you've defined it and it's not working, it's probably because you got rid of the attachInterrupt() call entirely, which does more than just assign an interrupt handler; it also enables the interrupt for that ADC. So: myADC....


1

I couldn't find the function being called directly, but there's a good example explaining how to attach interrupts to the ADC which works well: https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/STM32ADC/examples/SingleConversionInterrupt/SingleConversionInterrupt.ino If anyone knows the actual function being called directly ...


0

first you need to enable the interrupt (I don't know if the stm32 wrapper for arduino does it or not): NVIC_EnableIRQ(ADC1_IRQn); then you have to write ISR as gerben said: extern "C" void ADC1_IRQHandler() { //clear ADC flag } extern "C" because [as far as I know] the arduino projects are C++.


4

Just use a single 1ms timer interrupt and count them. Every 10 interrupts do both things. void interruptHandler() { counter++; // do things that happen every 1ms if(counter == 10) { // do things that happen every 10ms counter = 0; } }


Top 50 recent answers are included