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 [avr]

AVR is the family of microcontrollers used in Arduino boards.

1
vote
1answer
41 views

Use ATTiny as a battery-backed RAM?

So, I found an interesting article the other day, and I'm trying to build a project that could benefit from a battery-backed memory (no wear limits, but keeps data over power cycling). The article ...
0
votes
0answers
15 views

Moving timer-related code into a separate file causing timing inconsistencies?

I have written the following code, attempting to re-implement the Arduino micros function: main.c #include <avr/interrupt.h> #include <stdbool.h> #define CLOCK_CYCLES_PER_MICROSECOND (...
0
votes
0answers
18 views

how to fix USBASP Unknown USB Device (device descriptor request failed) - Win 10?

I just recently purchased Usbasp from Ali Express, when i'm connecting it to the windows 10 desktop in device manager its Unknown USB Device (device descriptor request failed). How to fix this error? ...
0
votes
1answer
58 views

Restoring all fuse bits on AtMega328P-PU

I'm worked with Low Fuse bits in AVRDUDEPROG 3.3. Fuses was non-inverted. And by mistake I enabled SUT1 and SUT0, when SUT0 was enabled. And when I programmed avr, it shows me error that avrdude.exe: ...
0
votes
0answers
15 views

What would cause fuses to be writeable but bootloader not to be writeable?

I am trying to burn a bootloader onto an ATmega328P-AN using an Microcenter knock-off Arduino Uno R3 as my ISP for several days with no luck. The farthest I've gotten is writing and reading a few ...
1
vote
0answers
15 views

Custom Arduino Due Random Lock up

I have built my own Arduino Due Circuit board. I am having issues with it randomly locking up. I have researched the libraries and have ruled out any issues with them such as the Wire library. I am ...
4
votes
1answer
88 views

Can I program a factory fresh Atmega328P through UART pins without burning a bootloader?

Can I program a factory fresh ATMega328P using the UART pins without burning a bootloader? These pins are TX, RX, VCC, GND, and DTR pins in the schematic below. They are not the ISP/SPI pins 10-13. ...
0
votes
1answer
19 views

About UART one transmitter multiple receivers

I have vector nav vn100 IMU that sends data serially rs232...I want to drive 4 servo motors using atmega32 upon roll angel from vector nav vn100..atmega32 can only drive 2 servos using hardware fast ...
0
votes
0answers
23 views

can an ISR change the value passed by pointer while the subroutine is executing?

So I am working on a project where the board plays a song on a buzzer using PWM and I want the song to stop when i press an external button typedef enum stateType_enum{ waitPress, debouncePress, ...
1
vote
1answer
44 views

Force TCNT to stay below OCRxA on ATmega328P

I'm using a timer and the TIMERx_COMPA ISR to generate a signal in "the background". This ISR is triggered when the timer reaches a certain value (OCRxA), which in turn can be changed by the user. ...
0
votes
1answer
30 views

About possibility of implementing kalman filter on atmega32 [closed]

I have searched on the internet on how to get Euler angels from IMU measurements,I found that kalman filter and mahony filter are used...kalman filter has a drawback of complex computations,but mahony ...
1
vote
1answer
30 views

.elf and .hex equivalency? (code, eeprom, fuses, and lock bits all in one)

I have all configurations (eeprom data, fuses, lockbits) of my ATMega168A together with the code in my C files. The compilation creates an elf file that I use as an all-in-one programming file for ...
0
votes
0answers
19 views

Installed configuration won't show up on Board menu

So I was following these instructions on the official site. Download this hardware configuration archive: breadboard-1-6-x.zip, Breadboard1-5-x.zip or Breadboard1-0-x.zip depending on which IDE you ...
0
votes
2answers
123 views

AVR software reset without watchdog

I wrote a generic avr program wrapper which already use the watchdog timer to restart - and after the watchdog reset - recover the the bad situation. After this recover process i have to restart the ...
0
votes
1answer
51 views

AVR-GCC can't call function located on fixed address

I wrote the following code: #include <avr/io.h> __attribute__((noinline, section(".app_start"))) void app_start() //app_start section starts at 0xFA0 { //register_packet_dispatch(...
-1
votes
1answer
110 views

Can the IDE handle a 32khz main clock?

I read somewhere that having the main clock be 32768Hz messes not only with micros() and millis(), but with some other stuff too. Is this true? Will I have to forgo the Arduino IDE to program for an ...
0
votes
1answer
48 views

Lines not pulsed fast enough (?))

Should this code pulse the PB3 and PB4 pins (MOSI and MISO of an Arduino Uno) at 2ms interval ? #include <avr/io.h> int main(void) { // for (byte i = 0; i < 32; i++) // pinMode(i, ...
0
votes
1answer
55 views

noisy output lines when waking up from a sleep

Using code similar to these examples from AVR https://www.microchip.com/webdoc/AVRLibcReferenceManual/group__avr__sleep.html my program causes my Adafruit Feather 32u4 to often sleep. When the ...
0
votes
0answers
40 views

Programming ATMEGA328p via AVR Pocket Programmer

I have a ATMEGA328p on a breadboard with the following connections to the 2x3 ICSP connector and its connected to AVR Pocket Programmer. While running AVRDUDE utility, i get the following error, ...
4
votes
2answers
323 views

How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?

I was just curious about how the AVR architecture manages errors that would cause a regular desktop program to crash. I'm talking about logical errors for example math problems that are undefined. ...
2
votes
1answer
150 views

Trying to run Timer1 in ATmega2560 with assembly

I have a slight problem with Timer1 in arduino (ATmega2560) while coding it in assembly. I try to run the Timer1 in CTC mode - I configure everything well in my opinion, but the TCNT1 just doesn't ...
0
votes
2answers
49 views

Why isn't the stack pointer changing in this simple sketch?

I'm playing around with context switching, and my first idea is to play with SP and see how it changes. However, Sp doesn't do what I expect. The sketch is below. I'm using an Uno R3. What I expect ...
3
votes
1answer
132 views

Assembly for loop repeating 2 times when it's only suppose to do it once

I'm programming an Arduino Nano so I belive that this question should be qualified for this SE. I am trying to dim up an LED using a for loop in AVR assembly. My problem is that the cycle is ...
4
votes
1answer
378 views

Why are Arduino timer registers not 0?

I'm trying to use the timer registers to do some timing on my Arduino Mega 2560. The output of the following code confuses me: void setup () { // Set up serial connection Serial.begin(9600); ...
0
votes
1answer
90 views

Arduino and AVR Serial Communication over USB

I have a Arduino Uno Rev3 and I would like to use a AVR development toolchain to write a program that performs serial communication over USB. Doing this using the Arduino IDE is fairly simple: void ...
2
votes
1answer
448 views

Generating 200 kHz pulse on Arduino Uno in normal mode

I need to obtain 200 kHz from Arduino Uno. I am using Timer0. I have configured it to run in normal mode and the Prescaler is set to clk/8 (the clock frequency of Arduino is 16 MHz). TCNT0 ...
1
vote
1answer
123 views

OpenOCD with FT2232H on Arduino Mega (ATmega2560)

I want to do on-chip-debugging on an Arduino Mega. According to its datasheet, the ATmega2560 chip supports JTAG. (IEEE 1149.1 compliant) Can I use a generic FT2232H interface to do on-chip-debugging ...
0
votes
0answers
242 views

50% duty cycle on phase-correct PWM on Timer 2

According to Ken Shirrif's article, Ken Shirriff's blog - Secrets of Arduino PWM (and the same article on the Arduino pages - Secrets of Arduino PWM), under the section Varying the timer top limit: ...
3
votes
2answers
339 views

How to read OC0A when in CTC (toggle) mode?

I have this code, which puts the Arduino into CTC mode with interrupts, and outputs a square wave on PD6 (OC0A): void setup_timer(double p_ms, double duty){ DDRD |= (1 << 6); // set pin 3 as ...
0
votes
2answers
67 views

Help - Atmega328p, converting a PWM servo code from pin9 to pin6

I found a working code that uses pin9 (PB1) on my Arduino for controlling a Servo, but in my project, an ultrasonic sensor is already using that pin/timer. I want to convert the code to use pin6 (PD6),...
0
votes
0answers
37 views

Problems using Arduino pcb as ISP with Atmel Studio 7

This issue has been bugging me for the past few days! I have learned a lot with my Arduino and the Arduino IDE over the past few years and decided to learn how to make faster, leaner code. I want to ...
0
votes
1answer
92 views

How to stop sending the last received char of UART echo function?

I developed a code for uart based ISR with linear buffers, the problem is that it keep sending the last received char in Arduino IDE. Here's the application code: #include "uart_new.h" void setup() ...
2
votes
3answers
728 views

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

In STM32 microcontrollers it is possible to use a technique that ST calls IAP, or In-Application Programming, in order to write to the Flash memory from your running application. They even have a nice ...
0
votes
1answer
147 views

Burn hex with optiLoader

Can optiLoader be used to burn custom hex? For example, there's hex representation stored in optiLoader.ino in image_328, if that value is replaced with content of my pre-compiled hex, should that ...
0
votes
0answers
136 views

Standalone Programmer

I am trying to make my small stand-allone programmer to work using this code: https://github.com/adafruit/Standalone-Arduino-AVR-ISP-programmer But when I hookup everything and press button to flash ...
1
vote
1answer
149 views

Trying to make sense of the coding style in Arduino libraries. (Particularly the Radiohead library)

I've been using the Arduino IDE for some time now, and I want to shift to coding for the bare AVR microcontroller. So I wanted to begin by porting required arduino libraries to C/C++. I started with ...
0
votes
2answers
2k views

sbi() and cli() implementation

I've often seen cli() and sbi() in Arduino code. I usually don't mind them as I know what they do (clear or set the bit given as second argument in the register of the microcontroller given as first). ...
0
votes
1answer
108 views

parse intel hex into SPI commands for arduino ICSP AVR

I'm attempting to use the arduino as an ICSP AVR to flash hundreds of ATMEGA's 90USB162. I'm having some difficulties when trying to do the actual flashing of the chip. I've go all the wires done ...
0
votes
1answer
209 views

How to scroll data in LED dot matrix through multiple modules?

I've been struggling in this issue for a long time, I know there are people who have done it. But, I don't have much experience in C to have the skills to design or develop such complicated functions....
2
votes
1answer
785 views

How does DDRD |= _BV(PD2) differ from digitalWrite(2,HIGH)?

I'm attempting to copycat the work of Louis Frigon's Toyota Aux Enabler. I have (with a lot of help on this site) managed to begin capturing and understanding messages on the AVC-LAN bus, but I can't ...
1
vote
1answer
323 views

bit_is_clear(ACSR, ACO) Instead of digital_read(1)==LOW

I am attempting to create a program for the atmega328P which will enable the aux input of a Toyota Corolla stereo. In order to do this, I'm bitbanging AVC LAN. Nearly all of my research comes from ...
0
votes
1answer
4k views

Can't burn bootloader through Arduino Nano clone ISP to atmega328p

I'm trying to use a Nano v3 as ISP to program an atmega328p on a board with ISP headers: I followed the instructions under https://www.arduino.cc/en/Tutorial/ArduinoISP which I think have been ...
0
votes
2answers
816 views

What's the difference between DDRB and pinMode?

It's my understanding that the following lines are equivalent. They seem to be interchangeable in my sketch: DDRB = 1<<DDB0; and pinMode(0, OUTPUT); Is the first form (DDRB...) setting a ...
0
votes
0answers
196 views

Arduino Timer 0 in fast PWM mode and micros()

I have the same problem as described on this topic I needed to set my prescale factor for Timer0 to 1 so I can get a 62.5Khz PWM out of pin 4 My issue is that now the delays() function on my ...
4
votes
1answer
65 views

How does the microcontroller know which clock to use?

I had seen some tutorials on how to assemble an Arduino on a breadboard. They all just place the external crystal oscillator according to the circuit and then, just burn the bootloader and it starts ...
0
votes
1answer
417 views

Arduino program to Blink L LED when input matches a set pattern

I have written a code that is supposed to blink the LED on PB5 pin, when a sequence of input matches a 4 digit password input from a keypad.But the program doesn't appears to be working as expected. ...
0
votes
1answer
104 views

Equivalent to POSIX mmap() in AVR-libc

Is there an similar function in AVR-libc/Arduino C++ to mmap()? I'm looking for a way to place machine code in memory at runtime and make it executable.
0
votes
2answers
525 views

Arduino analogWrite source code explanation

The source code for the analogWrite function looks like this: void analogWrite(uint8_t pin, int val) { ... sbi(TCCRnA, COM0x); OCRnx = val; ... } Where n is which timer (0, 1, 2...) ...
2
votes
0answers
311 views

Is it possible to put ATtiny85 to sleep while using TinywireS?

I have an arduino uno as the master I2C device talking to an ATtiny85 as the slave. What I want to do is have the Attiny85 receive a message from the UNO to tell it to power off which will then ...
2
votes
2answers
3k views

ATmega328p hangs on USART RX interrupt

I was able to use USART without interrupt driven and it worked perfectly! However, when I tried adding interrupt on USART_RX_vect, the program does not work as expected anymore. Below is my small ...