Hello. I am tinkering around with the Nano Every Arduino and write assembly code for the sake of learning. My C skills are ok, but I want to dive into assembler programming. What I accomplished so far: I am able to set the signal of PB0, PB1 and PB2 to either high or low (blinking). But I have no idea how to access the other pins. This is the .S part of my code.
;------------------------
.global test
.global led
;------------------------
test:
SBI 0x04, 1 ;set bit 1 in DDRB(?), DDRB instead of 0x04 doesnt work though
SBI 0x04, 0 ;set bit 0 in DDRB(?)
RET ;return to setup() function
;---------------------------------------------------------------------------
led:
CPI R24, 0x00 ;value in R24 passed by caller compared with 0
BREQ ledOFF ;jump (branch) if equal to subroutine ledOFF
SBI 0x05, 1 ;set PB1 to high
SBI 0x05, 0 ;set PB0 to high
RCALL myDelay
RET ;return to loop() function
;---------------------------------------------------------------------------
ledOFF:
CBI 0x05, 1 ;clear PB1
CBI 0x05, 0 ;clear PB0
RCALL myDelay
RET ;return to loop() function
;---------------------------------------------------------------------------
myDelay:
...
When I replace 0x04 by DDRB, it doesnt work anymore and I have no clue how to manipulate the data direction of the other ports. "Test" is a setup function called once at the beginning. I couldnt find help in the datasheet of the ATmega4809, so I am asking you for help. The c-part is trivial:
extern "C"
{
void test();
void led(byte);
}
//----------------------------------------------------
void setup()
{
test();
}
//----------------------------------------------------
void loop()
{
led(1);
led(0);
}
Is there a memory map/hex number for accessing the other ports or is writing to the other pins much harder to do? I tried to adapt Anas Kuzechies tutorial on youtube to the arduino nano.