; File: irTxSlowBiphaseATmega8\main.asm ; Device: ATmega8 ; Created: 21. 10. 2023 ; Version: 2023-10-22 #define round(X) (int(1.0*(X)+0.5)) .include ; implicitly included by Microchip Studio ; == General definitions == ; Set the CPU clock frequency in Hz: .equ F_CPU = 3_686_400 ; == IR definitions == ; Set some test commands: .equ IR_CMD_TEST0 = $D2 .equ IR_CMD_TEST1 = $79 ; SlowBiphase modulation definitions: .equ IR_WIDTH = 10 ; pulse or pause width in milliseconds ; == Hardware definitions == ; Set switch connection: .equ SWITCH_PIN = PINC .equ SWITCH_PORT = PORTC .equ SWITCH0 = 0 .equ SWITCH1 = 1 ; Set OC1A = IR output (high active -> LED on at high state): .equ OC1A_DDR = DDRB .equ OC1A_PORT = PORTB .equ OC1A = 1 ; == Register definitions == ; === Auxiliary registers === .def zero = r2 .def temp0 = r16 .def temp1 = r17 .def temp2 = r18 ; === IR TX registers === .def ir_intrCntr = r19 .def ir_data = r20 .def ir_mask = r21 .org 0 rjmp reset .org OC2addr ; Timer2 Compare Match interrupt rjmp ir_intr .org INT_VECTORS_SIZE reset: ; Initialize stack pointer: ldi temp0, high(RAMEND) out SPH, temp0 ldi temp0, low(RAMEND) out SPL, temp0 ; Initialize general registers: clr zero ; Set input pullups: in temp0, SWITCH_PORT ori temp0, (1<