Questions tagged [avr]

AVR is a 8- and 32-bit microcontroller core developed by Atmel. AVR was chosen as microcontroller for the first generations of the popular Arduino SBCs.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

Atmega644 timer0 not work

I setup timer0 on Atmega644: ...
0
votes
1answer
33 views

Controlling AVR reset via voltage divider

I have an AVR atmega32u4 which is being run on 3.3v. I program it using a avr usbisp, which runs at 5v.. The problem i'm having is driving the reset pin.. I currently have this schematic where ...
0
votes
0answers
24 views

How to flash ATtiny85 with clock quartz (32khz) again?

I flashed ATtiny85 once with simple program blinking for 1 second. F_CPU = 32768. I set low fuse byte to 0xe6 with avrdude. According to datasheet 6 = 0b0110 CKSEL is intended for low frequency quartz ...
0
votes
0answers
42 views

How to implement `analogRead` (Arduino) on AVR?

I'm trying to implement Pin class in C++ with digitalRead, digitalWrite, ...
0
votes
1answer
28 views

UART doesn't transmit all characters when using UDREn interrupt

Note: I am beginner :) MCU: Atemega328p In Method 1, I am using a UDRn data register empty interrupt once the transmit buffer is empty and inputting characters from ...
1
vote
2answers
58 views

Does this interrupt improve performance even with while loop in ISR?

Note: I am a beginner :) MCU: Atmega328p Which program below burdens the CPU the least? Would it be a significant difference? Objective: to make a more "efficient" serial monitor by ...
0
votes
2answers
58 views

Checking and reading bits using while loops

Note: I am a beginner :) MCU: Atmega328p I am struggling to understand how reading registers using while loops work in Embed C: For example AVR-C USART Protocol: ...
1
vote
1answer
73 views

Why would you right shift 8 bits for 8 bit register?

MCU: Atemega328P Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf (Page 143 - USART) Note: I am beginner :) Using the BAUD ...
0
votes
1answer
34 views

Unsigned int values gives negative number above the halfway point of max byte value?

MCU: Atemga328P: Datasheet:https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf Note: I am a beginner :) Considering a 2 byte ...
0
votes
1answer
34 views

Error Real Time Clock implementation AVR microcontroller

I want to create a real-time clock using ATmega328p microcontroller. The microcontroller's frequency is 1 MHz. So, I think I should use timer interrupts in CTC mode to generate interrupt every second. ...
1
vote
1answer
72 views

C++ AVR big code size & excess unused symbols in build file

I'm developing the program for the AVR microcontroller in C++. I have created a class that contains 8 methods(with constructors) but used only 3. Class code: ...
2
votes
1answer
86 views

C++ AVR microcontroller optimization problem

I'm faced with a weird problem. I'm developing a program for AVR. Microcontroller ATtiny85. Frequency 1 MHz. Programmer ...
1
vote
2answers
82 views

Tact switches only work once

I am trying to do a digital clock using an Atmega8A, LCD display (2x16) and four tact switches. Key number 1 is connected to pin PD2, number 2 to PD3, number 3 to PB6, number 4 to PB7. When you press ...
0
votes
0answers
34 views

How to replace AVR _delay_ms() with timer

Good day. I need problem with replacing _delay_ms() bultin function with timer. MCU: Atmega644@16Mhz My code (simplified): ...
0
votes
0answers
37 views

How to change LUFA default 8MHz crystal setting?

I have an Atmega32u4 micro controller with minimum hardware design. It has an embedded USB compatibility which can be enable/used with some software like LUFA. Everything works fine (the computer ...
0
votes
3answers
56 views

How to write own ISR handler

I am learning about avr programming and i know we have to use avr/interrupt.h library to use interrupt but my main reason to learn avr programming is to program without any library so i want to know, ...
0
votes
0answers
68 views

What is the fastest (in clock cycles) 16-bit x 16-bit unsigned integer division algorithm that will run on an ATMEGA1284?

What is the fastest (in clock cycles) division algorithm that will run on an ATMEGA1284? The dividend is an unsigned 16-bit number passed into the algorithm in a pair of 8-bit registers. The divisor ...
0
votes
1answer
31 views

Attiny861 programming current

What current does it consume during serial programming? According to datasheet it’s about 6000uA at 3.3V. I have to power it from a 10mA ldo, but now I’m not sure that it will be enough. To keep ...
1
vote
0answers
30 views

ATtiny85 Yikes Error While Burning Bootloader

I'm using an Elegoo uno to burn the ArduinoISP example code on to an ATtiny85 SMD. I wired the board according to the "#define USE_OLD_STYLE_WIRING" using pins 13/12/11/10. The wiring ...
0
votes
1answer
21 views

ADIF is set first or ADSC is cleared first?

I am using an ATmega8A for ADC conversion. I start ADC conversion by setting ADSC bit and wait till it clears by hardware to detect the end of conversion. I saw some people checking the ADIF bit to ...
0
votes
1answer
26 views

Use attiny as an external watchout timer

I like to failsafe an Atmega8 mcu despite having its own WDT. does it make sense that if I add an attiny to the circuit to check if each loop is taking a specific time, if not reset the Atmega chip?
1
vote
1answer
66 views

Execution of a piece of code in embedded

Can anyone explain to me step by step What is the result of executing the code below: DDRB = 0; unsigned char temp; temp = (PINB & (1 << 4)) >> 4;
0
votes
1answer
44 views

USB device detection problem on a Raspberry Pi

I have a device constructed from a Raspberry Pi 3 B and an AVR based USB device. The interconnection of these components is depicted in this picture. When RPI is on, data lines of keyboard will be ...
3
votes
0answers
102 views

ISR won't modify a global variable (IAR)?

First, some background on what I'm working on. I have a custom board with ATmega324A that I designed as part of a project I'm working on. Originally, software for the uC was written for GCC in Atmel ...
1
vote
0answers
66 views

ATtiny10 not running program

Im using an arduino uno to upload code via TPI to an Attiny10-TSHR on breadboard. Communicating with the chip works fine and uploading code but it never runs the code. By dumping the chip memory I can ...
0
votes
0answers
74 views

Chosing a small microcontroller

My IO/peripheral requirements are extremely minimal (I2C, a timer output, 2-3 GPIO). Problem is, I'm not sure how much "compute" I need, especially since there's not a lot of straightforward ...
1
vote
1answer
48 views

Why does the AVR Assembler linker think my data table is at the wrong address?

MCU: ATmega1284 Programmer: JTAGICE3 IDE: Atmel Studio 7.0.2397 Language: AVR Assembler I have a constant data table in flash memory. The linker thinks it is located at address 0x0090, so when I ...
2
votes
2answers
157 views

Accuracy problem with simple thermometer project

I have built a simple circuit that should send temperature mesurements using a radio module. The main component are: Attiny84a microcontroller RFM69HW transceiver LMT86 sensor The project is powered ...
3
votes
2answers
133 views

ATmega: Can one determine if an address is program memory or data memory?

On an Atmel ATmega1284 (or any of its AVR cousins), is there any way to determine at compile time or at runtime whether an address that is passed to a function belongs to program memory space or data ...
2
votes
2answers
64 views

How to store the last counting value in EEPROM in ATmega8 after power failure

I written a program to store the last counting value according to ATmega8 datasheet. but it didn't save the last value. The counter variable went to zero after power failure. Please check the ...
1
vote
0answers
49 views

Why can't I connect an external clock oscillator to an ATMEGA64A-AU?

I've decided to change my crystal oscillator for one of those smaller (and also expensive-er!) SMD clock oscillators on ATMEGA64A-AU. I've found this image on the web, which seems right: So I built ...
1
vote
1answer
47 views

Why UART voltage level on ATMEGA64A-AU are different?

Coming from this question I tried to measure voltage on RX1 and TX1 on ATMEGA64A-AU (the second USART) the RX1 voltage is about 3 volt and TX1 is 5 volt(straight out of the chip) which I've provided ...
0
votes
1answer
47 views

Why port B5 on ATMEGA64A-AU mailfunction after enabling USART function?

I've wire up ATMEGA64A-AU based on this schematic from here: I've tried to program a blink on pin B5 which has a LED on it: ...
3
votes
1answer
76 views

Why do I need to make an intermediate step on switching a pin from input to output On Atmega328p microcontroller?

On the Atmega328p datasheet p.99 The following was mentioned. Switching Between Input and Output: When switching between tri-state ({DDxn, PORTxn} = 0b00) and output high ({DDxn, PORTxn} = 0b11), an ...
0
votes
1answer
42 views

About Mahony filter for euler angles estimation

I have read some papers about mahony filter design..the filter corrects the error in gyroscope measurement using PI compensator....the error in gyro reading is calculated using the gravity vector.....
1
vote
0answers
62 views

ATmega328P presumably dead after probable SPI short circuit

I am trying to use an ATmega328P to interface an SPI device (RFM95W radio module). This worked pretty well (I could measure the correct signals on SCK, MISO, MOSI and CS), but after some programming ...
0
votes
1answer
28 views

Issue with avr spi slave interrupt in proteus ATmega8

I want to get some data from spi, but spi interrupt doesnt work. I get a message and a pause in proteus instead of a signal on LCD. How to fix this? My code: ...
0
votes
1answer
74 views

Why does the Atmega328 USART get trapped in a loop?

I have an Atmega328 micrprocessor. I connected its RX/TX pins to an SIM808 module and uploaded this code to the processor to communicate with it and send commands: ...
2
votes
1answer
119 views

AVR setting certain PWM frequency and duty cycle is not working right

I am prototyping a simple LED dimmer on an Arduino Uno (Atmega328p) and I have issues with the PWM frequency and duty cycle I am trying to adjust. To get a frequency of 200Hz flat I am using the CTC ...
1
vote
2answers
29 views

ATmega48PB: wdt in interrupt mode still reset the MCU

I read the datasheet and this question, but there's still something wrong here. Here my wdt init code: ...
1
vote
2answers
60 views

Changing delay duration in _delay_us() changes code size

I was programming an ATtiny13A when I accidentally noticed that when I change the delay time in _delay_us() my code size changes. Here's the sample code: ...
3
votes
1answer
56 views

AVR: do I have to wait for the internal pullup to stabilize?

speaking of an ATMega2560 (not Arduino!), I connected a simple push-button between PB6 and GND. There is a bootloader and ...
0
votes
1answer
61 views

program stops execution after reception of a single character over UART

Why this simple program stops execution after reception of a single character over UART? Normally the program blinks LED every half of second. When character is received the ISR should start. Nothing ...
1
vote
0answers
95 views

How to uplad program into Arduino Nano Clone with CH340?

I've started to build a Arduino Nano with CH340g using this schematic: Which use the CH340 chip : With one difference, I've use SPI pin to program the MCU. I've uploaded OptiBoot to Atmega328 and ...
0
votes
1answer
60 views

Why isn't software USB/TTL on ATmega328p working?

I've tried to implement an AVR-CDC project. I found this website which is recommended by V-USB (I know it is pretty old project.) I drew this schematic: I've built a PCB basef on it and then I've ...
0
votes
1answer
104 views

How to make an Arduino (ATMEGA16U4) like, software USB to serial on Atmega8u?

I've start to build a project base on Atmega328 and I need to connect to it(via USB for availability of the USB port) for debugging (I prefer to debug it with serial communication), and I don't want ...
1
vote
1answer
57 views

Inconsistent bootloader failure ATMEGA328P

I am creating a wireless charger with a microcontroller on it. I have assembled 3 boards. One of them has a microcontroller that works fine - burns bootloader and uploads code sketch fine. However, I ...
0
votes
2answers
49 views

Smoke calculation with mq2 sensor

How to calculate the amount of smoke output from the mq2 sensor?
0
votes
1answer
46 views

I2C Communication in AVR

The first step in a TWI transmission is to transmit a START condition. This is done by writing a specific value into TWCR, instructing the TWI hardware to transmit a START condition. Which value to ...
2
votes
1answer
115 views

Configuring Atmega32 timer using the oscillator without prescaling gives wrong delay time

I am using AVR atmega32 microcontroller. The code below is supposed to toggle the LED connected to PORTD. The frequency of the oscillator connected to the ...

1
2 3 4 5
35