A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [avr]

AVR is the family of microcontrollers used in Arduino boards.

Filter by
Sorted by
Tagged with
5
votes
1answer
382 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
189 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
737 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
234 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 ...
2
votes
2answers
471 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
91 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
1answer
144 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
1k 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
196 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
180 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
159 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
4k 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
136 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
261 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....
0
votes
0answers
194 views

AVR-Toolchain for Arduino crashes on Mac OSX 10.11.6: Hints or debugging help needed

My Arduino IDE does not compile any project since I updated from Mac OSX 10.6.8 to 10.11.6. I even tried reinstalling and also manually installing the original AVR-toolchain. But the behaviour did ...
2
votes
1answer
1k 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
542 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
2answers
6k 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
1k 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
236 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
67 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
562 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
122 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
815 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
383 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
4k 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 ...
0
votes
0answers
160 views

HMC5883L stops reading when x-axis value get to positive value

I've been looking for a solution for this problem for quite a time I tried different I2C libraries; like, I2C master library using hardware TWI interface * Author: Peter Fleury But the same ...
1
vote
2answers
469 views

ATmega328p - ISC00 with INT1?

I was reading about external interrupts using the ATmega328p, and I saw in the chip datasheet under the paragraph "Bits 3:2 – ISC1n: Interrupt Sense Control 1 [n = 1:0]" the following table: Value | ...
1
vote
3answers
170 views

What's in an Arduino?

I've been using an Arduino Uno Rev. 3 for a few projects and would like to switch to using a bare Atmega328 chip so I can keep everything on the same board. I've seen the Arduino on breadboard ...
0
votes
1answer
511 views

I bought ATmega328p with bootloader and I can't erase it

I bought an online deal which had 10x ATmega328p with bootloader installed. I thought I can erase the bootloader once I got the order (I want to write custom task without a bootloader) but my ...
1
vote
2answers
2k views

Do AVR delay functions (_delay_us() and _delay_ms()) use timers?

I'm trying to determine if the AVR delay functions _delay_us() and _delay_ms() use timers in such a way that I can't use those timers for other functionality in my code. If so, what timer does it use? ...
1
vote
2answers
2k views

Why we can wake Arduino Uno from sleep using only pin 2?

Can we use other pin as an interrupt to wake Arduino Uno from sleep ?
2
votes
2answers
300 views

Is there an ICRn CTC mode interrupt vector?

I can use the CTC waveform generation mode to loop to OCRnA and trigger the corresponding TIMER1_COMPA_vect interrupt. // CTC mode TCCR1A &= ~(1 << WGM10); TCCR1A &= ~(1 << WGM11);...
0
votes
2answers
154 views

How do I use an ATMega 328 (not P) chip with an Arduino board?

I just burned the bootloader on an ATMega328 chip and then I put in on the Arduino board. But when I try to upload a program to it, it says programmer not in sync and programmer not responding. For ...
2
votes
2answers
889 views

programming arduino in pure c

I'm trying to flash pure c-code to arduino Mega2560 board from linux using avr-gcc & avrdude. Compilation is done , now trying to flash using avr-dude, getting error as "avrdude: stk500_recv(): ...
0
votes
2answers
628 views

Including an arduino library in Eclipse Neon (undefined reference to)

I'm trying for the first time to use Arduino Libraries (Servo.h & Servo.cpp in this case) in Eclipse IDE. So far I've managed to compile and run Arduino code using this tutorial (I suppose many ...
1
vote
1answer
82 views

Can't send Data to LCD1602 with I2C

I've been doing fine with my LCD1602 I2C configuration but I discovered that command and data functions are the same even though I change the RS command/data bit, but the result is the same. This is ...
0
votes
3answers
430 views

More speed from ATMEGA328 Internal Clock

I have a board that is designed and produced. It was designed to use an Atmega328 with the internal clock. There is no space on the board to place an external clock. After completing these and testing ...
1
vote
3answers
684 views

Shift Register on ATMEGA328p

I want to learn more about the shiftout function used with Arduinos and used the implementation with my ATMEGA328p. The Setup This is the original shiftout function used in Arduino Programming, ...
0
votes
1answer
605 views

Attiny85 not recognized at windows startup

I'm using an Attiny85 to interact with a computer using an USB connection, and everything works fine except when I restart my computer and the Attiny85 is connected. When Windows end to boot up the ...
0
votes
1answer
184 views

I2C begginer with I/O expander with mega328p C code

I've just started with the I2C protocol. I read about it in the datasheet, other documents, blogs and videos. So, I started to develop my code and I think I did my first success, I succeeded to send ...
0
votes
1answer
830 views

How to find the pin map for the LCD 1602 I2C adapter module?

I'm working with I2C to work with my LCD 1602 and the I2C adapter. This module has 16 pins and I don't know how to communicate with it. I2C sends 8-bit packets. What are the commands to deal with ...
2
votes
1answer
581 views

Building Custom Bootloaders

Recently I was checking out the Atmel's AVR series and I found the Atmega328PB. I am really familiar with Arduino's environment. So I thought if somehow we could bootloader it with Arduino bootloader. ...
1
vote
1answer
138 views

Is setting AVR TWCR for mega328p TWEN in each function necessary?

I found this useful website explaining for to configure and implement the TWI for mega328p, but what I found not so obvious is that in the website they set TWEN in every function, while in the ...
0
votes
0answers
22 views

Programming ATUC256L4U using only Arduino ISP

I heard that you can program any AVR Microcontroller by just using Arduino ISP Can I program ATUC256L4U by just hooking it up to Arduino ISP and Caps, Crystals and etc. Or do I need to do some more ...
0
votes
1answer
32 views

What if I detach AVR micro controller from the Arduino Board after uploading program?

What if I detach AVR microcontroller from the Arduino Board after uploading program? Does the microcontroller still have the program on it? Or the program will be deleted? On the board where does ...
0
votes
1answer
374 views

TWI Wire.setClock() on non arduino AVR MCU issue

Using an Atmega168P - programmed by means of avrdude with the .hex file generated by Arduino IDE. The following code sets the 8 MHz Atmega's TWI interface to just 15.625 kHz: Wire.begin(); // ...
0
votes
1answer
166 views

Arduino IDE compiling for non-arduino AVR boards

Using: Arduino IDE 1.8.2 the board manager from https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json an ATmega168P MCU in TQFP I was able to run my code successfully by modifying ...
3
votes
3answers
2k views

Can I compile a sketch for my attiny85 without an arduino board?

I have a lot of Raspberry Pi's laying around, so I want to use those to program my attiny85 chips. The problem is that most of the code examples, libraries, and documentation out there assume you're ...
2
votes
1answer
1k views

Arduino EEPROM retains old data after flashing with a new program

I have a custom 5V 16Mhz Arduino Uno (a breadboard Uno of sorts) that runs the grbl firmware. After the initial flashing I can see all the settings (through the serial monitor) and everything works. ...