Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Basic interrupts on ATtiny26

2007-02-16 by Manne Tallmarken

Hi all,
I am trying to make my first assembler program that handles interrupts. On
PB[6:0] I have som leds and on PA[7:6] i have two buttons. The leds goes
on with a logic one from the port and the buttons is in tri-state when not
pushed and goes to logic zero when pushed.
I just trying to get a binary counter to show up on the leds when i am
pushing the buttons but nothing happens.
Does anyone know what could be wrong?
Regards, Manne

Here is the code:

.include "tn26def.inc"

; Interrupt service vectors

.org $0000
        rjmp Reset
.org IOPINSaddr
        rjmp IntPins

; define registers
.def TIME=r16
.def TEMP=r17

; define constants
.equ PORTB_IO=$7f       ; pb[6:0] = output
.equ PORTA_IO=$00       ; pa[7:0] = input

Reset:
        ldi     TEMP, RAMEND    ; set stack pointer to RAMEND
        out     SP, TEMP        ; (SP is one byte on attiny26)

        ldi TEMP, PORTB_IO
        out DDRB, TEMP
        ldi TEMP, $00           ; all lights off
        out PORTB, TEMP

        ldi TEMP, PORTA_IO
        out DDRA, TEMP
        ldi TEMP, (1<<PA3) + (1<<PA6) + (1<<PA7)                ; enable
pullup resistors
        out PORTA, TEMP


        ; set up interrupts

        ldi TEMP, (1<<PCIE1)
        out GIMSK, TEMP ; enable individual interrupt PCIE1 ( PB[7:4],
PA[7:6], PA3 )
        ldi TIME, $00   ; start from 0

        sei

loop:
        rjmp loop


IntPins:
        inc TIME
        out PORTB, TIME
        reti

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.