Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [atmega]

ATMega is a family in the AVR series of Atmel microcontrollers. This is the main microcontroller of the Arduino prototyping platform. Please Specify the specific part number in your question.

50
votes
7answers
83k views

How can I get my atmega328 to run for a year on batteries?

Scenario I have created a nice electronic door lock for my dorm room. It is currently an Arduino Diecimila with a servo [un]locking the door. It has a numerical keypad with 3x4 buttons and 5 LED's (2 ...
33
votes
7answers
44k views

What happens if I omit the pullup resistors on I2C lines?

Just now I realized that the I2C data and clock lines (SDA and SCL) must have pullup resistors. Well, I've built a couple of clocks using the DS1307 RTC (see datasheet) according to the schematic ...
20
votes
5answers
28k views

ATMega8: why do VCC and AVCC have to be connected?

I often read that it is good practice to connect VCC with AVCC. Even in the ATMega8 datasheet it says so: AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It ...
18
votes
5answers
84k views

How do I read digital input on ATmega16?

What do I have to do to read a digital input (pushbutton) on ATmega16? Do I have to enable pullup-resistors or can I use a 10 kohm one? What would some simple code be be? Just a simple 'Turn the ...
17
votes
9answers
3k views

Reading a huge number of analog sensors in real time

I'm trying to build a MIDI-like controller that has a neck like a guitar. On that neck, there is a huge matrix of pressure sensors. The controller will emulate 3 strings. The way this works is: ...
17
votes
6answers
27k views

Using the ATMega328 with the internal oscillator?

I have a project that I think would be best suited for an ATMega328P. However, in every simple project I've seen, people always hook up a 16MHz external oscillator. From what I can see, it should have ...
15
votes
2answers
4k views

How can I use my SMD Arduino to program a separate DIP ATmega328?

I have an arduino with a surface mounted (SMD) microcontroller: I know how to use a DIP arduino as a programmer for a DIP ATmega328. It's easy --you just pop your microcontroller in the holder. ...
14
votes
2answers
33k views

Protecting AVR flash from reading through ISP?

I'm trying to protect whole flash from reading through ISP. It has bootloader, able to self program application section. Setting lock byte to: LB1/LB2 will not ...
14
votes
1answer
1k views

How can V-USB screw up the built-in SPI of an ATmega328p?

I'm working on a V-USB project that shows up as a Keyboard using an ATmega328p. The USB part is working great (it's not my first V-USB project), but after I start the V-USB stack with ...
13
votes
3answers
9k views

Driving DC motors with MOSFETs and a microcontroller?

I'm developing a nano quadcopter using an Atmega328 microcontroller, powered at 3.3V, and very small brushed DC motors. The average current used by these motors is about 800mA @ 3.7V. Initially, to ...
12
votes
1answer
3k views

How should one switch from using an Arduino as a programmer to an external programmer?

Part two of a three part series on transitioning from Arduino to a plain AVR microcontroller and minimum supporting components (part one, part three) I've seen a lot of people ask this on the ...
11
votes
4answers
6k views

AVR flash memory corruption

This question is related to AVR deprogramming itself. Project info: We have a battery powered product using an ATMEGA644P. The application permanently runs in sleep mode and only wakes up once a ...
11
votes
2answers
5k views

How do you determine if a new microcontroller is defective?

I've never dealt with parts being defective strait from digikey, but 3 new Atmel ATmega164A's that I've received have been exhibiting extremely odd behaviour. I narrowed it down to something to do ...
10
votes
10answers
9k views

Linux / Mac AVR Programming Suite?

I have been coding and using Arduinos for quite some time now. However I am ready to move up to using straight AVR chips without the arduino bootloader. My question is what are resources to do this? ...
10
votes
2answers
7k views

Any reason not to use Timer0 on AVR?

Just a basic question... For arduino/avr/ATMega328 I find lots of examples using Timer1 (there's even a whole library for it) but rarely any that utilize Timer0 (or Timer2). Now, I know that using ...
10
votes
2answers
3k views

What to do with unused analog inputs?

I am working on an application using ATmega328p atmel microcontroller. I started with the 28 PDIP version, but now I want to use the 32 TQFP, which I noticed has 2 extra inputs after compiling my ...
10
votes
3answers
20k views

What is the minimal set of parts for a circut with this AVR microcontroller?

My Arduino Uno has a ATMEGA328P-PU microcontroller, and bunch of other stuff on the board. I'd like to program the chip without the Arduino software, and only the minimum of other components. I want ...
10
votes
3answers
11k views

Correct usage of a pin change interrupt

I'm trying to use pin change interrupts to detect pressed buttons. Until now I have never worked with these kind of interrupts and there are some problems, so I want to make sure if this is the ...
10
votes
2answers
4k views

Do Atmega328 chips have pseudo-unique IDs?

I'd like a couple of Atmega328s to run the same program, but they're going to interface with each other and need unique IDs. Is there any such ID or serial number hard-coded on the chip?
10
votes
2answers
5k views

Need help understanding AVR ATMEGA / ATTINY timer mirrored output

I am trying to use Timer1 of Atmel AVR microcontroller, either AtMega328 as used in the Arduino, or the ATTiny85, to output two clock signals which are mirror images of each other. The frequency I am ...
9
votes
5answers
4k views

Start off with embedded C with ATmega32 (ATmega AVR series)

I have a ATmega32 board laying around and I figure it would be perfect to start off with microcontrollers. I once did some babbling in embedded C (thats when I got this board) but the flow was stopped ...
9
votes
4answers
21k views

Using a 16 MHz crystal on a ATMega328p

How would I need to set my fuse bits on a ATMega328p to use a 16MHz crystal? I tried this on my own and killed the last atmega I had. I'd like some advice this time. The crystal I am using is this ...
9
votes
1answer
9k views

ATMega328 External AREF Connection

From the ATMega328 datasheet, section 24.9.1: The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin. From the Arduino reference ...
9
votes
1answer
176 views

Do the new “PB” variants of ATmega have a bug in the brown-out detector?

We've been using ATmega48/88/168/328 microcontrollers successfully for many years in many of our products. We have now considered to switch from the A and PA variants to the new PB variant (because we ...
9
votes
1answer
1k views

AVR timer speedup on ATmega328

When running at clock prescaler of 64 on ATmega328, one of my timers speeds up for unknown reasons at a particular time in the execution. I am using two timers on ATmega328 to generate the clocking ...
8
votes
7answers
1k views

How to find the UART line is free for send data

I have several boards that communicate together with Rs485. They have ATMega series microcontrollers such as atmega168p or ...
8
votes
2answers
5k views

SPI device prevents ISP programming

I have an ATmega8 with a Nokia LCD 5510 connected to it. Everything works great on a breadboard and my next step is to move it to a more permanent board. My problem is that I can't program the ATmega8 ...
8
votes
1answer
609 views

AVR: overclocking ADC

This is a quote from ATmega32 datasheet: ...
8
votes
2answers
7k views

AVR interrupt service routine not executing as fast as expected (instruction overhead?)

I'm developing a small logic analyzer with 7 inputs. My target device is an ATmega168 with a 20MHz clock rate. To detect logic changes I use pin change interrupts. ...
8
votes
2answers
2k views

Minimum ATMega328 speed with UART

I am looking at designing a low-power project that will have an ATMega328 running at a low speed for lower power consumption. The current plan is to have the UART hooked up to a RF Link Receiver for ...
8
votes
3answers
3k views

Will checking the backup voltage on an RTC drain it's backup battery?

I'm working on an ATMega project that will be keeping time and I'm trying to make it so you have an option of either software time (millis() based), DS1307, or DS3231 (ChronoDot) RTCs. At the most ...
8
votes
1answer
4k views

Can an ATmega or ATtiny device signature be read while running?

While programming an ATtiny or ATmega, avrdude prints the device signature, in this example it is an ATtiny. avrdude: Device signature = 0x1e910a Can I read this ...
8
votes
2answers
820 views

Need help reverse engineering and understanding a small circuit

I am an electronic student, and one day I opened an energy meter I have at home called EM21, and found out that its body is comprised of two major components: The meter body, that connects to the ...
8
votes
2answers
14k views

Easiest way to create a USB HID device

I am working on hacking an RC remote controller I own. What I intend to do is open it up, and tap into the potentiometers. I want to read the analog values delivered by the potentiometers, and send ...
8
votes
1answer
589 views

How to buffer an ATMEGA for millisecond-level power interruption without strange behavior?

I have an ATMEGA328p-pu arduino with an LED + shift-register strip circuit attached over SPI. When it turns on, it increases a variable in EEPROM to advance the display mode. We have the brownout ...
8
votes
1answer
158 views

Unexpected Atmega16 response over UART

Unexpected Atmega16 response over UART Brief problem summary I have flashed an Atmega16 with code that should result in the Atmega16 sending back whatever character I send to it via a terminal. I ...
7
votes
5answers
2k views

EEPROM endurance in energy meter?

I am designing an energy meter for electricity billing purposes by converting an analogue energy meter and counting the number of pulses given by the analogue meter's LED. Since power may be cut off ...
7
votes
3answers
2k views

What determines sizeof(int)

Regarding the standard data types, What is the size of an integer in ATmega controllers? And what determines the size, is it just the compiler? Or is it in the hardware design of the controller itself ...
7
votes
4answers
14k views

How to shift out 16 bits fast on arduino board

I'm coding a system that need to shift out 16 bits fast from a uint16_t variable to two paired 74HC595 shift registers. I'm running the code on an Arduino (atmega328@16Mhz) and the shiftOut in the ...
7
votes
3answers
2k views

Upgrading an Arduino Duemilanove from ATMega168 to ATMega328

I have purchased an ATMega328 from SparkFun with the Arduino bootloader pre-programmed. My intention is to replace the ATMega168 I currently have in my Duemilanove. Is this as simple as swapping the ...
7
votes
1answer
8k views

When do we need an external crystal for an Atmega chip?

I have created a microcontroller circuit, based on the most used circuits I could find on the Internet -- which use an external crystal. As I know, Atmega16 has an internal oscillator which operates ...
7
votes
2answers
31k views

Real maximum current for ATmega328?

Everything I read says that the ATmega328 can provide 40mA per pin. However when I've measured the actual current provided by one pin it was showing 80mA. It was the same on every pin I tested. Anyone ...
7
votes
6answers
3k views

Exploiting stack buffer overflows on an Arduino

Is it possible exploit stack buffer overflows on an Arduino board?
7
votes
2answers
11k views

Differences between atmega32u2 and atmega32u4?

What are most important differences between ATMega32u2 and ATMega32u4?
7
votes
1answer
1k views

How do I transition from using the Arduino IDE to plain avrdude/make?

Part three of a three part series on transitioning from Arduino to a plain AVR microcontroller and minimum supporting components (part one, part two) I already know how to use an Arduino as a ...
7
votes
1answer
11k views

Backup AVR with avrdude

I'm heavily experimenting with ATtiny AVR's and I can't afford to buy a new AVR for every experiment, so I thought up a backup script. The idea is that I can bring my AVR back to factory defaults ...
7
votes
2answers
8k views

Problems with homemade RS232-to-TTL converter board based on TI's MAX232

I've designed an RS232-to-TTL converter board based on TI's MAX232 IC that I plan to use to program a few custom Arduino boards that I have. However, I'm having trouble with the board and I'm hoping ...
7
votes
2answers
2k views

Generating servo signal in atmega2560

I'm new to AtmelStudio. I need to know how to generate a servo control signal using timer modules of atmega2560. I'm using an Arduino Mega board. (please refer the last paragraphs of this page for ...
6
votes
2answers
18k views

How to get the PWM frequency and duration of each pulse?

I have an ATmega8 and I started working on servo motor HS-645MG. What frequency works with the HS-645MG? How do I get the frequency of PWM and the duration/length of each pulse? Is there a calculation?...
6
votes
4answers
5k views

Do I have to use a MAX232 chip?

I am trying to interface my ATmega chips to the computer using a serial interface. I have read that this can be done directly by connecting the appropriate pin between the chips and the serial pin. ...