26
votes
Are high speed crystals better at something compared to 32768 Hz crystals?
STM32L4 cannot directly use the LSE as a PLL source. The reason for this is also the reason why you'd prefer a higher frequency crystal: phase noise.
The 32768 Hz crystal oscillator generates a sine ...
24
votes
Accepted
Why does compiler optimization flag cause function definitions other than main() to break program in AVR ATMega C code?
These are not bugs that you are encountering. The problem goes deeper than just compiler optimization flags. It is a pure coincidence it happens to work at all.
The code isn't compiled properly ...
24
votes
Are high speed crystals better at something compared to 32768 Hz crystals?
You simply cannot derive any arbitrary clock from 32768 Hz. Your PLLs can typically only do integer multiples, and with the dividers in typical MCU clock trees, you could do but a very limited set of ...
24
votes
Accepted
Tie all unused GPIO to GND?
The PIC24FJ64GA004 Datasheet specifies the general practice for unused I/Os:
2.8 Unused I/Os
Unused I/O pins should be configured as outputs and driven to a logic low state. Alternatively, connect a ...
17
votes
Tie all unused GPIO to GND?
Apart from the valid reasons given in answers, if you are developing a circuit board, it's always useful to have spare IO brought out to a small but convenient test point just in case you suddenly ...
17
votes
How can a microcontroller (such as an Arduino Uno) that requires 7-21V input voltage be powered via USB-B which can only run 5V?
An arduino uno is not a microcontroller; it's a dev board that has a microcontroller on it, along with a bunch of supporting components. One of those supporting components is a device called a voltage ...
14
votes
Is it a good idea to perform I2C Communication in the ISR?
In the olden days, when we had a single thread of execution, and many sources of interrupts, you kept the ISR as short and quick as possible, so that it is able to keep up with many frequent interrupt ...
13
votes
Why does compiler optimization flag cause function definitions other than main() to break program in AVR ATMega C code?
You know that something goes really wrong when at address 0 there is no vector table, which would be an array of RJMPs or ...
13
votes
Can I control any transistor (NPN/PNP) using a GPIO pin of my MCU? Is my schematic correct?
To "is my schematic correct"...
The below circuit is wrong. First, Q1 will try short out the rail when PB5 is driven HIGH. Second, Q1's base is a diode to GND so Q1 will try to clamp PB5 to ...
12
votes
Are high speed crystals better at something compared to 32768 Hz crystals?
If you require to do some things related to frequency or time done with better than the datasheet mentioned 0.25% precision for LSE trimmed operation at the system clock frequency, then you can't use ...
12
votes
Accepted
RTC super capacitor is discharging very fast
This explains the issue.
When 5V_uC is off the RTC will be working from supercapacitor and the microcontroller is also off at that time.The clock output of the RTC will be in enabled state.
You can'...
12
votes
Accepted
What happens if a microcontroller stays in reset?
A couple of issues:
A MCU usually has a default reset setting where all GPIO are set as inputs. This is an advantage in terms of current consumption, but it is a disadvantage in terms of ruggedness ...
11
votes
Accepted
ATmega8515 - odd results when auto-detecting external SRAM
There are two possibilities I can think of as to why the lines will be repeatably holding their value when accessing the non-existent RAM.
You have the bus keeper functionality enabled on the data ...
11
votes
Accepted
What happens if an MCU boosts its own supply voltage while running?
I've done that with an ATtiny84 with no problems.
When in sleep mode parts of the circuit (such as the analog section) are powered down and the supply voltage is dropped from 5V to 1.8V with only the ...
11
votes
Why does compiler optimization flag cause function definitions other than main() to break program in AVR ATMega C code?
Thank you for providing the dump output! You've captured the smoking gun:
See ATmega8515 Datasheet | Microchip page 54:
The first instruction must be rjmp .init (...
11
votes
STM32 for loop slows down code too much
Speaking about performance without mentioning how you compile the code is kind of pointless. It shouldn't be a mind-blowing realization that optimized code runs faster than code with optimization ...
11
votes
Is it a good idea to perform I2C Communication in the ISR?
I don't believe it's a good idea, in general. The I2C protocol allows for clock stretching, which means that any I2C device you're trying to talk to can effectively stop your bus, or at least dork ...
10
votes
Low consumption resistor pair
May I offer a different approach?
Instead of turning off the voltage divider, reduce its current drastically and buffer the voltage.
simulate this circuit – Schematic created using CircuitLab
10
votes
Tie all unused GPIO to GND?
It might be relevant, but it depends.
And you already talk about two scenarios, you mention tying unused IO pins to ground (without mentioning any resistors so reader may assume direct connection), ...
10
votes
How do input pins work?
Setting pull-up or pull-down switches an internal resistor (or something similar) between the input pin and either Vdd or GND.
So you effectively have either of these:
simulate this circuit – ...
9
votes
Accepted
How are different GPIO frequency modes implemented?
Mostly, the slew rate for GPIOs is increased by adding more drivers in parallel like the one shown below.
I have shown above an image of a GPIO that has 2 drivers. Each has an independent enable as ...
9
votes
What is the function of the comparator in the ATMEGA328p ADC block diagram?
The shown ADC converter works by stepwise control of the 10-bit DAC, comparing the result with the analog input signal from the mux.
It does this via a "binary chop" / "successive ...
9
votes
What happens if a microcontroller stays in reset?
If you hold the MCU in the reset state, it will do nothing, but that's not necessarily what you want.
Power-wise, consumption will probably be higher than in the low power sleep states. And of course ...
9
votes
Help in identifying an abnormal PCB found suspiciously
As surmised in the comments already, this is most likely a cheap "mood light" USB device, which has two RGB LEDs for increased brightness, and a button to change the mode / color...
If you ...
8
votes
Accepted
How to prevent photoresistor sensor from draining battery
Sleep on the watchdog timer (or other low power timer) instead and then only power the photodetector at the end of each sleep.
Connect the top of the photoresistor circuit to a GPIO so that you can ...
8
votes
Accepted
What is expected resistance of MCU power supply pins?
I am hesitant to apply external voltage to it
As long as it is current-limited, it should be OK.
Visual inspection does not show any bridges, but it is hard to tell with LQFP pitch.
You need a good ...
8
votes
Advice on making a quad-directional power/data connector
Instead of four discrete pins, use a 4-circuit circularly-symmetrical connector.
These connectors may be plugged-in in any orientation. Regardless of orientation, each contact is connected to the ...
7
votes
Absolute Maximum ratings of a device
Your assumptions are mostly correct. Many chips have ESD protection diodes from the pins to VCC, and it is the power dissipation of the current flowing through them that would damage them. The limit ...
7
votes
Are high speed crystals better at something compared to 32768 Hz crystals?
Consider a STM32L412K8U6TR. The only direct use the 32.768kHz crystal has is for the RTC (it can optionally be fed to a GPIO as well). The watchdog is clocked off the internal low frequency RC ...
7
votes
Accepted
Can I control any transistor (NPN/PNP) using a GPIO pin of my MCU? Is my schematic correct?
No, you can't control any transistor, because there are different kinds of transistors, some may require more current or more voltage than any microcontroller can provide.
Your schematic has no base ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
microcontroller × 9701stm32 × 939
pic × 881
arduino × 758
c × 631
embedded × 523
adc × 453
avr × 421
microchip × 374
voltage × 312
arm × 292
mosfet × 291
led × 287
programming × 275
power-supply × 271
uart × 269
pwm × 266
sensor × 262
i2c × 262
spi × 254
usb × 242
atmega × 239
transistors × 218
digital-logic × 217
interrupts × 207