avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] emulation problems


From: Darkb_
Subject: [avr-gcc-list] emulation problems
Date: Tue, 10 Aug 2004 19:24:48 +0200

Hi, well i wrote a little program that will turn on 8 leds randomly
and will wait until you press the same switchs to generate the next
led number.

The random number is based in a timer counter timer0, that is suposed
to increment the value each cycle of the MCU, but in the emulation,
the TCNT0 never start to count, i think that it's a problem in the
initialization, here is the code

; este programa debe de replicar el juego 'simon' con 6 leds

.include "m16def.inc"

.def ent = R16
.def sal = R17
.def temp = R18

.org 0x0000
        rjmp    RESET

RESET:
        
        ldi               temp,LOW(RAMEND) ;Initiate Stackpointer (Subroutines!)
        out             SPL,temp
        ldi              temp,HIGH(RAMEND)
        out             SPH,temp
        
        ldi     temp, 0xff
        out     DDRB, temp              ; PORTB como salida
        ldi     temp, 0x00
        out     DDRD, temp              ; PORTD como entrada.

        ; Prescaler of the timer = 1024, 4 MHz/1024 = 3906,25 Hz
        ; that equals a timer tick every 256 ┬Ás.

        ldi             temp,(1<<TOIE0);enable timer interrupt
        out             TIMSK, temp
        ldi     temp, 0x05              ; preescalar de timer0
        out             TCCR0, temp             ; 
        
        ldi             sal, 0x01               ; inicializa salida= 0x01

loop:
        out     PORTB, sal
        in              ent, PIND
        com             ent                             ; sal&=(~ent)
        and             sal, ent
        cpi             sal,0                   ; ya presionaste todos sal=0?
        brne    loop                    ; si no son todos ceros, regresate a 
loop
        in              sal, TCNT0              ; ya fueron ceros, ahora 
TCNT0->sal
        rjmp    loop


do you know how do i have to initialize timer0 to have internal counting?

Thanks a lot!

-- 
Darkb_
"software is like sex, it's better when it's free"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]