2,385 questions
0
votes
1
answer
40
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 ...
2
votes
1
answer
85
views
Arduino Nano not reading Data from UART Shell properly
Recently I've been getting into bare-metal programming with the Arduino-Nano, and wanted to play around with the UART protocool. I made a simple "shell" using rust on my host machine that ...
-1
votes
1
answer
39
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
0
answers
77
views
Simavr - ATmega328P timer flags behaving oddly
I am using Simavr to simulate an AVR ATmega328P chip, so I dont know if this is a problem in the simulation or if it happens in the MCU too.
When using the timer0 in CTC mode the TOV0 flag seems to be ...
1
vote
1
answer
91
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
1
answer
76
views
AVR Embedded question (rstack and cstack)
I have a project in college where the main in asm has to call a function in c, but I don't know how to initialize the stack (rstack and cstack). I mention that the project is on an atmega16.
Main asm ...
0
votes
2
answers
149
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-...
0
votes
0
answers
88
views
Rust AVR-atmega328p Assembler global_asm! "jmp addr" Error "instruction requires a CPU feature not currently enabled"
I'm on Rust with AVR atmega328p,
using
nightly-2024-11-12-aarch64-unknown-linux-gnu (default)
rustc 1.84.0-nightly (81eef2d36 2024-11-11)
I have a global_asm! macro which compiles Ok in a bin main....
1
vote
2
answers
77
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 ...
0
votes
1
answer
38
views
getting "Invalid opcode 0xFFFF at PC=0x5200" on proteus
this is my code for atmega32 in assembly language. It will toggle led on pd5 after pressing the push button 10 times, but in proteus I am getting this error:
Invalid opcode 0xFFFF at PC=0x5200
I ...
4
votes
1
answer
58
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 ...
2
votes
1
answer
71
views
ATmega328p Memory Addresses
I learning to program the ATmega328p microcontroller in C and Assembler:
In C, I define DDRB = 0x24.
In Assembler, I define DDRB = 0x04
Can someone explain this difference in addresses (does that ...
3
votes
2
answers
95
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, ...
1
vote
1
answer
68
views
avr-gcc ATmega4809 problem with `.rodata` section
(This is a follow up of this question)
The following program doesn't work (in ATmega4809)
#include <avr/io.h>
void f(const char str[])
{
if (str[0] == 'a') // <-- here is the problem. ...
3
votes
1
answer
86
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 ...