Is there a forum dedicated to AVR assembly programming?
AVR assembly is how I amuse myself - I say this because I don't want to be caught in the Assembly vs C debate. I'm looking for a place where AVR ASM freaks can share ideas/experience.
I'm using Atmel Studio with the Atmel ICE, AVR Dragon, STK600 (plus too many attachments), a gaggle of Xplained boards, and a whole herd of tiny, mega, and xmega chips. I've come a long way in the last five years but, with the exception of a few books, I'm learning in a vacuum. Data sheets provide a few tidbits. I've read a great many of them. App notes, though, seem to be exclusively C, which is really too bad.
Sure, building code techniques from the ground up can be very interesting. At some point, though, I'd like to check my answer.
If you are still with me, I'll attempt to add a small function from a larger Xmega32E5 TWI section. When combined with the whole, it works fine. But I do wonder how someone else would do it.
; TwiWr_Wait 21May2020 ; ----------------------------------------------------------------------------- ; Description: ; Waits for MSTATUS.WIF to be set. Checks ARBLOST, BUSERR, and RXACK, and ; then returns SREG_T to indicate success (0) or error (1). ; ; Success is defined as: ; - WIF = 1, and ; - ARBLOST = 0, and ; - BUSERR = 0, and ; - RXACK = 0 (ACK) ; Parameters: ; None. ; General-Purpose Registers: ; Parameters - ; Modified - ; Constants: ; TWIM_WRFLAGS_bm - (0b_0001_1100) RXACK, ARBLOST, and BUSERR flags ; Returns: ; SREG_T - success (0) or error (1) ; Note: ; If STATUS.WIF is never set, this function never returns. ; Just so you know. TwiWr_Wait: push r16 TwiWr_Wait_wait: lds r16, TWIC_MASTER_STATUS ; r16 = STATUS sbrs r16, TWI_MASTER_WIF_bp ; if (WIF == 0) rjmp TwiWr_Wait_wait ; goto TwiWr_Wait_wait andi r16, TWIM_WRFLAGS_bm ; if (WRFLAGS == 0) breq TwiWr_Wait_exit ; success: goto exit ; else set ; error: SREG_T = 1 TwiWr_Wait_exit: pop r16 ret
Oh, that's rude. The code editor didn't even have an ASM option.