23 votes
Accepted

What's the maximum time an interrupt service routine can take to execute on ATmega328P?

If nothing else is running in the MCU, then you are free to take as long as you like in the ISR. But, this is a bad habit to get into, and it means that if you want to do anything else, you'll likely ...
user avatar
  • 140k
19 votes
Accepted

Seven-segment display seems to draw little current

First of all +1 for measuring your display. Too often we get questions here about "I saved money by buying cheap from Alibaba but it don't work. Now please spend you valuable time helping me out". ...
user avatar
  • 14.1k
18 votes
Accepted

Due to overcurrent, shouldn't I be extremely cautious when setting an I/O pin as Output?

As others have said, you shouldn't have a problem as long as you double check your code. If you do get it wrong, by and large the ATMega IO pins will limit themselves to about ~80mA due to internal ...
user avatar
17 votes
Accepted

Is it safe to drive I/O pins of an unpowered AVR ATmega328P?

You may be interested in EEVBlog's video about powering an MCU without connecting the power pins. If you drive the I/O pins on the MCU, you may end up powering up the MCU through its protection diodes....
user avatar
  • 1,019
15 votes

Compress .hex file for micro-controller

You can not compress the hex code, you can only try to reduce it. Try different? compiler settings (maximum optimization and optimize for size) Pick your way through the source code and see what can ...
user avatar
  • 14.1k
12 votes

Is the ATMEGA328P's serial baud rate quantised?

It is a fully digital system. It must operate in discrete steps. This is the formula from the datasheet: UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud ...
user avatar
  • 8,396
11 votes
Accepted

Atmega328P - How is brown-out-detection supposed to work?

The brown out detector will put the chip into reset mode if the voltage on the Vcc pin drops below the threshold. When in reset, all GPIO pins go into high impedance mode and no code executes. When ...
user avatar
  • 9,315
11 votes

What's the maximum time an interrupt service routine can take to execute on ATmega328P?

In the worst case, an ISR can run until the next interrupt of the same type occurs again. But in general, it's poor design practice to spend more time in an ISR than absolutely necessary, because it ...
user avatar
  • 164k
11 votes

Compress .hex file for micro-controller

The MCU cannot execute compressed code. However, there are some things you can do: Instead of using full fledged library functions, create some or all of the functions yourself; this way you can ...
user avatar
11 votes

Due to overcurrent, shouldn't I be extremely cautious when setting an I/O pin as Output?

You should be cautious but not terrified about it. Setting a pin output and driving it to the other direction will cause a lot of current to flow, but it also does not blow up in smoke immediately. ...
user avatar
  • 87k
9 votes
Accepted

AREF on atmega328 if analog is not used

The AREF pin has no required connection. If an external reference is needed, it can be connected to the AREF pin, but then care has to be taken to not connect AREF to an internal voltage source. If ...
user avatar
  • 1,002
9 votes

Due to overcurrent, shouldn't I be extremely cautious when setting an I/O pin as Output?

Considering this type of circuit is avidly encouraged, how it doesn't seem to bring any troubles? Because when engineers set up the I/O for their device, they are careful to ensure that they do not ...
user avatar
  • 5,719
9 votes
Accepted

Possible to buy Atmega328p with programmed Flash and EEPROM?

In my experience, this has only economical for gigantic production runs; the cost of this value-add service can be high (I've been quoted a multiple of the price of each controller.) Consider the cost ...
user avatar
8 votes

Timer 1 (16 bit): Why is overflow interrupt sometimes missed?

The problem is that you are not eliminating the actual issue with the ATOMIC statement- the counter is incrementing in hardware and there will be times when an interrupt is pending but not completed. ...
user avatar
8 votes

Compress .hex file for micro-controller

In addition to the excellent suggestions provided in the other answers here I want to comment that there can be a huge difference in how much compilers (and linkers) can optimize code. I worked at a ...
user avatar
8 votes

Compress .hex file for micro-controller

The first step for any kind of optimisation is find out what's doing it. Your first move should be to get the linker to dump the address of every identifier in the build. That's all functions and all ...
user avatar
  • 5,719
7 votes
Accepted

Is power cycle reset different from reset pin reset?

Is power cycle reset different as compared to reset pin reset? Yes. There are some semiconductor behaviours where only loss of power will allow previous behaviour to resume. An SCR is a type of ...
user avatar
  • 16.5k
7 votes
Accepted

is a voltage regulator required for atmega328p when powering from boost converter at a set voltage?

is a voltage regulator required for atmega328p when powering from boost converter at a set voltage? No it is not. The ATMega is "just" some logic circuits in a chip. So is the CPU in your PC and in ...
user avatar
  • 78.7k
7 votes
Accepted

Is the ATMEGA328P's serial baud rate quantised?

As already mentioned, this quantization is fundamental to the architecture, which can only divide the source clock by an integer. However, your problem is quite avoidable. The ATmega UART can ...
user avatar
7 votes
Accepted

LED- Resistor, does the position matter?

No, it does not matter. There are several cases: The LED works: in this case the resistor will limit the current flow, and does not matter if it is before or after, since it is connected serial. The ...
user avatar
6 votes
Accepted

27 pin Arduino Microcontroller

On the pcb I have, i see only 27 pins for the microcontroller This is very hard to believe, unless some idiot designed the board. Even if only 27 pins are actually used in a circuit, any competent ...
user avatar
6 votes

Why there are 7 pins in I/O PORT C of Atmega328P as against 8 pins normally?

There are no more leads on the package. If you look at the die of the ATmega328p (on wikipedia) you will see 32 wire bonding points. But there are less leads on the package, choices have been made, ...
user avatar
  • 20.4k
6 votes

Compress .hex file for micro-controller

There is no "practical" way to run compressed code on an AVR so your problem becomes "how do I optimize the size of my firmware". Toolchain tricks (ie. you don't have to modify your code): What is ...
user avatar
  • 8,396
5 votes

Is it safe to drive I/O pins of an unpowered AVR ATmega328P?

No. At the input of most pins on a device such as the AVR ATmega328 there are diodes to protect the chip from electrostatic discharge (ESD). These diodes connect to the supply rail of the device. If ...
user avatar
5 votes

Please critique my schematic

Is it correct to connect ULN2803 in parallel to achieve more max current per channel? See Tony's comment below. However yo have another problem: ULN2803 has high VCEsat, so your 5V motor will only ...
user avatar
  • 57.4k
5 votes
Accepted

NE555P Frequency Drop to 0 after a couple of minutes?

It is very difficult to see, but as far as I can tell it looks like you have the wrong pinout for the 555 timer. The pins on the right-hand side should be numbered 5-8 from the bottom up, not from the ...
user avatar
  • 20.2k
5 votes

Led Bulb Flicker when duty cycle is below 40%. What is wrong with circuit?

This looks like a mess waiting to catch fire or electrocute someone. You don't say where this is, but almost certainly some part of the AC line is tied to ground somewhere. That means you have a ...
user avatar
5 votes
Accepted

Realizing a multitasking program with Timer Interrupts

Have I understood the concept of multitasking right? there are different flavours of "multitasking", some more sophisticated than others. in a nutshell, it is about time sharing to provide the ...
user avatar
  • 4,155
5 votes
Accepted

Servo interfering with 433MHz RF

simulate this circuit – Schematic created using CircuitLab
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible