; File: avr-eb32-test.asm ; Device: AVR16EB32 ; Created: 2024-08-31 ; Version: 2024-08-31 ; Author: jofe .include .macro xout ; eXtended "out" .if @0 > 0x3F sts @0, @1 .else out @0, @1 .endif .endmacro .def tmp0 = r16 .cseg .org 0 rjmp reset .org TCB0_INT_vect ; 0x1A rjmp timerIsr .org INT_VECTORS_SIZE ; 0x3E reset: ; Set PA0 as output: sbi VPORTA_DIR, 0 ; Initialize and start TCB0: .equ TCB0_CCMPVAL = 65_000 ldi tmp0, low(TCB0_CCMPVAL) xout TCB0_CCMPL, tmp0 ldi tmp0, high(TCB0_CCMPVAL) xout TCB0_CCMPH, tmp0 ; ldi tmp0, TCB_CCMPEN_bm ; 0x10 ; xout TCB0_CTRLB, tmp0 ldi tmp0, TCB_ENABLE_bm ; 0x01 xout TCB0_CTRLA, tmp0 ldi tmp0, TCB_CAPT_bm ; 0x01 xout TCB0_INTCTRL, tmp0 sei loop: rjmp loop timerIsr: ; Clear interrupt flag: ldi tmp0, TCB_CAPT_bm ; 0x01 xout TCB0_INTFLAGS, tmp0 ; Toggle output PA0: sbi VPORTA_IN, 0 reti