2,383 questions
4
votes
2
answers
131
views
avr-g++ - Undefined reference to register Y upon linking
I have a weird problem when doing inline asm and compiling/linking with avr-g++ (version 16, fresh from the Git). I think this might be a bug of the tool chain, but I wanted second opinions in case I ...
0
votes
1
answer
44
views
AVR 8-bit: Reusability vs. Efficiency?
My implementation of an API function doing a simple SPI transfer, offering a void *intfPtr parameter to pass a "device descriptor" which I am using to pass the I/O port and pin for SPI chip ...
0
votes
1
answer
101
views
“avrdude: verification error; content mismatch” error when programming AVR based microcontrollers
When programming for an AVR compatible micro controller, such as the Atmega328p, you're facing an error after successfully building and uploading a first time, but all subsequent times result in an ...
0
votes
0
answers
60
views
yl-69 sensor - adc conversion does not change adch and adcl - avr assembly
The YL-69 sensor(for soil moisture using a comparator circuit LM-393) is functional. When tested with C code on the Arduino IDE, it prints the correct values on the serial monitor. However, when ...
0
votes
1
answer
70
views
Switching on 10 LEDs using push button
#define __SFR_OFFSET 0
#include <avr/io.h>
.global main
main:
ldi R16, 0xFD ; Set PD1–PD6 as outputs, PD0 as input
out DDRD, R16
ldi R16, 0x01 ; Enable pull-up resistor on ...
-1
votes
1
answer
49
views
I was working with this 7-segs led timer i encountered this error "Invalid opcode 0xFFFF at PC=0x0014" in proteus
.include "m8def.inc"
.org 0x0000
rjmp RESET
.org 0x0020
rjmp TIMER0_OVF_ISR
RESET:
ldi r16, low(RAMEND)
out SPL, r16
ldi r16, high(RAMEND)
out SPH, r16
ldi ...
1
vote
1
answer
110
views
Is there a way to create a static array in the .data section, where its length is calculated by the size of the .bss section on the Arduino?
I'm just wondering if there is a way I can tell the compiler that I want to create a static array inside the .data section of the Arduino's SRAM, where the array's size is calculated using the size of ...
0
votes
2
answers
172
views
Binary size bloats 20x if moved from src/main.rs to examples/
I'm making a library for Arduino Uno in Rust from scratch. Currently, there's a basic Serial.write print example in the src/main.rs, which on compilation is around 500 bytes (cargo b --release).
$ avr-...
1
vote
2
answers
109
views
How to get an ATtiny24A MCU into sleep mode?
I am experiencing somewhat a peculiar phenomenon. I am trying to get an ATtiny24A into sleep mode. I had a working code before, but through revisions and testing of other parts of my program it seems ...
4
votes
1
answer
77
views
Where is the offset of the Y register from the call/stack frame in avr-gcc coming from?
On the avr-gcc website (https://gcc.gnu.org/wiki/avr-gcc#Frame_Layout) it says that the frame pointer (Y register) is off by one byte so Y+1 points to the bottom of the frame. However when I compiled ...
3
votes
2
answers
118
views
Difference between AVR's "ADC r18, r18" and "ROL r18"
AVR has both ADC (Add with Carry) and ROL (Rotate Left through Carry) instructions.
However, it seems to me like ROL is not needed at all, and ADC r, r fulfills the same purpose.
As far as I can tell, ...
3
votes
1
answer
96
views
Problem with avr-g++ 13.3.0 passing const char array as parameter in ATmega4809 (40 pins)
The following code doesn't work in ATmega4809:
#include <avr/io.h>
#include <util/delay.h>
void f(const char str[])
{
if (str[0] == 'a'){ // <-- here is the problem!!! The program ...
1
vote
1
answer
315
views
Can't correctly print to serial UART using AVR-c on ATmega328P Arduino Uno
I'm trying to program an ATmega328P Arduino Uno "bare metal" to print to serial over the USB connection to my computer, however I only see replacement characters (�) being printed, both when ...
1
vote
1
answer
287
views
AVR ATtiny1626 bizarre infinite interrupt problem
I have an ATtiny1626 code that I'm in the early stages of just getting the modules going on my custom board for my client.
I had some issues with my interrupts being called indefinitely over and over.
...
4
votes
2
answers
195
views
AVR Instruction Sets and "missing" instructions by device
I'm trying to build a table of "missing" AVR instructions by device.
For want of any available documentation, I've been comparing the source-code of avra, gavrasm and avrlass and I don't ...
0
votes
1
answer
111
views
Why will data not save to SPDR over SPI in this code?
I am trying to learn SPI on an Arduino Uno (ATmega 328 MCU). I'm working in the Arduino IDE however I am programming in actual C, not the Arduino library. I have setup SPI functions from looking at ...
-1
votes
1
answer
187
views
Where is the program counter stored in the AVR architecture
I'm writing an emulator for the ATMEGA328P, and after looking through the datasheet I could not find the specific address at which the PC is located, a ton of information is mentioned on other ...
2
votes
2
answers
140
views
Saturating addition optimization in avr-gcc
I am programing for ATtiny13 and I have to do a lot of saturating additions.
Trying to optimize them, it seems that avr-gcc just doesn't know how to optimize anything at all. All of this was tried ...
0
votes
1
answer
91
views
data segment of AVR store nonsense after compiling
So i'm trying to change the first element of an array that i'm storing in sram and i checked if the data after compile is equal to the value of pre-initialaztion and it wasn't equal. so this my code:
....
-1
votes
1
answer
171
views
Why do I need to put the millis() function inside the main loop to trigger the ISR?
I'm trying to replicate that earbuds functionality that consists in a multifunctional button. If you press this button x amount of times, in a period of time, the earbud will do something depending on ...
0
votes
2
answers
277
views
UART issue in ATmega2560 and Microchip Studio
Using Microchip Studio, I have implemented a code snippet to send a character via UART using ATmega2560 and a USB-to-TTL device.
The code for sending a character is as follows:
void USART0_Init(...
4
votes
2
answers
767
views
char arrays in PROGMEM
In a program, I have a lot of arrays of different length strings, and each array is declared as an array of pointers to those strings, like:
static const char * num_tab[] = {"First", "...
-1
votes
2
answers
480
views
RTOS on ATtiny85, 8 bit MCU. Is it possible?
Everyone, I am working with ATtiny85 using Arduino IDE. Recently I was learning about RTOS. I want to ask if it possible to run RTOS on ATtiny85 microcontroller? According to my knowledge it may be ...
1
vote
2
answers
155
views
AVR128DB28 communication with SD card over SPI failed
I am trying to achieve communication between an AVR128DB28 microcontroller and an SD card over SPI.I'm programming it in Microchip Studio, programming is done through an MPLAB SNAP over UPDI. The ...
0
votes
1
answer
107
views
libgcc subroutines documentation for avr-gcc
I disassembled some C++ code with the avr-gcc compiler in godbolt and often found calls to libgcc subroutines like __udivmodhi4 or __mulhi3.
Where can I find good and insightful documentation about ...