Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 08, 2016, 12:56:56 12:56


Login with username, password and session length


Pages: [1]
Print
Author Topic: How to simulate AVR counter in avrstudio  (Read 2181 times)
0 Members and 1 Guest are viewing this topic.
aamir
Hero Member
*****
 Muted
Offline Offline

Posts: 510

Thank You
-Given: 37
-Receive: 229


« on: August 26, 2008, 07:05:49 07:05 »

I am using ATMEGA8515 now i want to simulate counter function in  it in avrstudio . If i toggle PORTB0.0 PIN IN AVR SIMULATOR NO change in counter register.How to simulate counter function.
Logged
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #1 on: August 26, 2008, 08:43:38 20:43 »

Hi Aamir,

Quote
If i toggle PORTB0.0 PIN IN AVR SIMULATOR NO change in counter register.How to simulate counter function.
See the AVRStudio's help. It can't simulate all the modes of Timer/Counter modules.
Better check it with Proteus or VMLAB. See also that DDRB has been set correctly.

reagrds,
sam_des
« Last Edit: August 26, 2008, 08:46:48 20:46 by sam_des » Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
Belgitaes
Junior Member
**
 Muted
Offline Offline

Posts: 42

Thank You
-Given: 19
-Receive: 17


« Reply #2 on: August 28, 2008, 02:15:49 14:15 »

Hope this one help you i little

Code:
;------------------------------------------------------
; AT90S8515:toggle PORTB0.0 PIN IN AVR SIMULATOR
; Belgitaes
.include "8515def.inc"
;-----------------------------------------------------------
; Definicion de constantes y variables
; --------------------------------------------------------
; Pila
  .equ          PILA                   =0x0FF
;-----------------------------------------------------           
.DSEG       
; MEMORIA RAM       
    .ORG                (PILA+1)
;----------------------------------------------------
;            Vectores de interrupcion
;----------------------------------------------------           
.CSEG       
    .ORG     0x0000         
    rjmp        RESET                        ; RESET

    .ORG 0x0007
rjmp OverFlow0 ;OverFlow Temp/Cont0
; --------------------------------------------------------
;                       RUTINA DE RESET
; --------------------------------------------------------
RESET:  cli
        ldi        r16,HIGH ( PILA )         
out        SPH,r16         
ldi        r16,LOW (PILA )                         
out        SPL,r16         

;*******DESDE AQUÍ VUESTRO CODIGO*****

;Configuracion De Los Puertos
;...............................................
out ddrB,r16;DDRB has been set As Output
cbr r16,0x01; Configuro Patilla 0 Del Puerto B A 0
out portB,r16; Escribe 1111 1110
;...............................................
sei ;Autorizacion Interrupcion General

;TimsK:
;                                                    |***Cuando El Bit Esta A 1 En TOIE0   
;|--7--|--6---|--5---|--4---|--3---|--2--|--1--|--0--|***Se Valida La Interupcion
;|-----|------|------|------|------|-----|-----|-----|*** Timer /Counter0
;|TOIE1|OCIE1A|OCIE1B|  -   |TICIE1|  -  |TOIE0|  -  |** El Bit TVO0 Se Modifica
;|-----|------|------|------|------|-----|-----|-----|** En El Registro TIFR
;   0     0      0     0       0      0     1     0
;                                           *

ldi r16,0x02
out TimsK,r16

;.............................................................................
;Contador Ascendente Incrementa Desde 0 Hasta 256
;Se Activa El Bit TOV0 De Tifr Cada Vez Que El Contador Pasa De FF A 00 ( Overflow)
;............................................................................
             ;256 x 8 = 2048 microsegundos
ldi r16,0xA3 ;2048/100 = 20,48 X 8 = 163,84
             ;163 Decimal = A3 Hexadecimal
             ;256 Decimal = 100 Hexadecimal - A3 = 5D
             ;5D = 93 x 8 = 744 microsegundos
out TcnT0,r16
;............................................................................
;TccR0:
;|--7--|--6--|--5--|--4--|--3--|--2--|--1--|--0--|** Selector Del Factor De
;|-----|-----|-----|-----|-----|-----|-----|-----|** Pré-Division Del Reloj
;| MSB |     |     |     |     |CS02 |CS01 |CS00 |** Define Prescaler
;|-----|-----|-----|-----|-----|-----|-----|-----|** Por Señal Externa Pin T0
;                              |  0  |  1  |  0  |** Reloj Systema /8 CLK I/O/8 (Desde El Pre-Escalador)

ldi r16,0x02
out TccR0,r16
;................................................
;Hacer Un Programa Que Tendra Un Bucle Infinito
;Que Haga Lo Que Quiera ! No Se Me Occure Nada !
;Asi Que Configuro La Salida Por Hacer Algo
;Del Puerto Para Cuando Salga Del Bucle .
;.........................................
ldi r16,0x01

;..........................................
;1º Vuelta Bucle Infinito
;2º Vuelta Bucle Salta A Stop
;.........................................
SaltoEnVacio:
tst r16
breq stop
rjmp SaltoEnVacio

OverFlow0:
out PortB,r16 ;toggle PORTB0.0 PIN IN A 1
clr r16       
out TcnT0,r16 ;Contador A 0
out TimsK,r16 ;Deshabilito Interrupcion
reti         ; Retorno de La Interrupcion

;****HASTA AQUÍ VUESTRO CODIGO********

STOP:        rjmp        STOP   ;FIN DEL PROGRAMA
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC