Questions tagged [avr]

AVR refers to two families of either 8- or 32-bit RISC microcontrollers

The AVR is a modified Harvard architecture 8-bit RISC single chip microcontroller which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to One-Time Programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

External links:

2299 questions
0
votes
3 answers

Disable code based on existence of Constructor

I am trying to disable some code based on whether the code creates an Object or not (or calls a function or whatever). Sounds a bit strange, I know. In my library it is possible to create 2 objects, each object needs an interrupt service routine…
0xhexdec
  • 17
  • 6
0
votes
1 answer

avr assembly. getting array of reverse sum

If you input the array 1 2 3 4 5 -1 the output is supposed to be 15 14 12 9 5. I'm getting seg fault. What am I doing wrong? .global reverse_prefix_sum reverse_prefix_sum: ld r24, X+ cpi r24, -1 breq done2 push r24 call…
0
votes
1 answer

Arduino IDE - fails to link compiled subsections in avr-gcc

Hello StackOverflow Community, Recently I have been noticing that my Arduino IDE has simply been failing to actually be able to compile and run to any board, from the TTN Uno (which is a smaller Arduino Leonardo), ESP8266 (both in module and WeMos),…
0
votes
1 answer

Using ArduinoCore-avr library in arduino project

I want to use ArduinoCore-avr in my project. I don't want to use arduino's IDE default function setup() and loop(). I also don't want to use arduino's IDE to compile and burn hex file into my device. ArduinoCore-avr library is downloaded from…
Lion Lai
  • 1,862
  • 2
  • 20
  • 41
0
votes
2 answers

Entering in switch case resets to zero every variable and some tips

I wrote this code in my exam, but it have some problems(and because of this i get failed). While debugging through my board(i've got an atmel atmega328p Xplained mini), i don't know why, but while entering in the main switch and between switch…
RawCode
  • 3
  • 4
0
votes
1 answer

ERROR SPI on ATmega328P of Arduino

I use SPI on ATmega328 with raw code, data is transferred correctly, but the value return just correct in the second time. I don't know why. I think the data buffer register doesn't update immediately, when I push the button (this is video left is…
0
votes
1 answer

How to use external library in my own Arduino library?

Good evening! I'm writing an Arduino library. Inside it, I want to instantiate an object from another library whose constructor needs to be passed a parameter, but I don't want to hard-code such parameter. I need some guidance about how to do this.…
Nicolás
  • 23
  • 5
0
votes
1 answer

Using of variable instead of hard-coded string

I plan to to use led display containing TM1637. Programming language: avr-gcc I've found this library: https://github.com/project37cat/TM1637-lib-AVR/blob/master/tm1637.h and it works for me by using of function led_print in this…
Mr.Holub
  • 3
  • 1
0
votes
2 answers

Accomplishing simple conditional tests with Assembly

I am trying to code a simple if-else statement in assembly however, the ret returns to the start routine instead of the intended test routine. How to fix this? Thank you. start: ldi r16, 0 call test rjmp start test: cpi r16, 0 …
0
votes
1 answer

AVR timer with external interrupt error

I came across a project where I want to print the distance measured from an ultrasonic sensor to a LCD. The schematic of the design is as follows: The corresponding code: /* C Program for Distance Measurement using Ultrasonic Sensor and AVR…
0
votes
1 answer

Assembler Pin Change Interrupt in Atmega328p - what am I doing wrong?

I am trying to do my first steps in programming a PCI in Assembler. It works in the simulator (AVR Studio), but it does not work when uploaded to my Arduino. The idea is to toggle a light when an interrupt is triggered. Please help me find out what…
0
votes
1 answer

How to take a snapshot of a changing variable (such as a timer) in C?

I am currently programming a Teensy micro-controller and want to setup a pause function for a game. I have been able to create a timer from ISR counter overflows, however I haven't been able to work out how to pause this counter. I have…
david_10001
  • 492
  • 1
  • 6
  • 22
0
votes
1 answer

Can UDR be written inside USART_RXC interrupt handler without checking the UDRE flag in AVR ATMega32?

I have been trying to understand this code which is supposed to echo each byte received on the AVR's USART interface using interrupt. #include #include #define USART_BAUDRATE 9600 #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -…
0
votes
3 answers

Get characters from macro name to optimise macro function

I'm using the following macro function #define setAsOutput(bit, i) { *bit ## _DDR[i] |= (1 << bit[i]); } to simplify defining and setting some register values // registers volatile uint8_t *FOO_DDR[] = {&DDRA, &DDRA}; uint8_t FOO[] = {PA1,…
101
  • 8,514
  • 6
  • 43
  • 69
0
votes
1 answer

AVR controller, button issue

I have problem, microcontroller simply doesnt register when i press button. As it didnt happened. Here is my code. #ifndef F_CPU #define F_CPU 1000000UL #endif #define bit_is_clear(byte, bit) (!(byte & (1 << bit))) …
user7585238
  • 63
  • 1
  • 9