Anda di halaman 1dari 3

ESCUELA POLITCNICA NACIONAL INGENIERA ELECTRNICA Y REDES SISTEMAS MICROPROCESADOS Nombre: Mara Elena Hurtado Sandoval.

Fecha: 20 de abril de 2012.

Cronmetro en dcimas de segundo Diagrama de Flujo

Cdigo .include "m164pdef.inc" .def tempo=r16 .def cont=r17 .dseg TIEMPO: .byte 2 .cseg .def .org .org .org aux=r21 0x00 rjmp 0x02 rjmp 0x04 rjmp ENCERAR CONTAR INICIO

INICIO: ;CONFIGURACIN DE PUERTOS DE I/O ser tempo out ddra,tempo out ddrc,tempo clr tempo out ddrd,tempo ;CONFIGURACIN DE PULL-UP ldi tempo,0b00001100 out portd,tempo ;GARANTIZO PULL-UP in tempo,mcucr andi tempo,0b11101111 out mcucr,tempo ;INICIALIZACIN DEL SP ldi tempo,low(ramend) out spl,tempo ldi tempo,high(ramend) out sph,tempo ;HABILITACIN DE INTERRUPCIONES ldi tempo,0b00000011 out eimsk,tempo ldi tempo,0b00001010 sts eicra,tempo sei ldi ldi out ldi out ldi ldi LAZO: out out rjmp CONTAR: call ldi out dec brne inc ldi ldi add clr adc ld SALVAR tempo,0b00000010;preescaler de 8 tccr0b,tempo cont SALIR aux xh,high(tiempo) xl,low(tiempo) xl,aux aux xh,aux aux,x porta,xh portc,xl lazo cont,50 tempo,249 ocr0a,aux tempo,0b00000010;CTC tccr0a,tempo xh,high(tiempo) xl,low(tiempo)

ldi ENCERAR: call clr rjmp SALVAR: push in push ret SALIR: pop out pop reti Simulacin tempo SALVAR

cont,50

cont SALIR

tempo,sreg tempo

tempo sreg,tempo tempo

D1
1

D2
2

D3
CONTAR

U2
40 41 42 43 44 1 2 3 9 10 11 12 13 14 15 16 29 27 4 PB0/XCK0/T0/PCINT8 PB1/T1/CLKO/PCINT9 PB2/AIN0/INT2/PCINT10 PB3/AIN1/OC0A/PCINT11 PB4/SS/OC0B/PCINT12 PB5/MOSI/PCINT13 PB6/MISO/PCINT14 PB7/SCK/PCINT15 PD0/RXD0/PCINT24 PD1/TXD0/PCINT25 PD2/INT0/RXD1/PCINT26 PD3/INT1/TXD1/PCINT27 PD4/OC1B/XCK1/PCINT28 PD5/OC1A/PCINT29 PD6/ICP/OC2B/PCINT30 PD7/OC2A/PCINT31 AREF AVCC RESET ATMEGA164P PA0/ADC0/PCINT0 PA1/ADC1/PCINT1 PA2/ADC2/PCINT2 PA3/ADC3/PCINT3 PA4/ADC4/PCINT4 PA5/ADC5/PCINT5 PA6/ADC6/PCINT6 PA7/ADC7/PCINT7 PC0/SCL/PCINT16 PC1/SDA/PCINT17 PC2/TCK/PCINT18 PC3/TMS/PCINT19 PC4/TDO/PCINT20 PC5/TDI/PCINT21 PC6/TOSC1/PCINT22 PC7/TOSC2/PCINT23 XTAL1 XTAL2 37 36 35 34 33 32 31 30 19 20 21 22 23 24 25 26 8 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

D4
4

C1
1uF

D5
5

D6
6

D7
7

ENCERAR

CONTAR ENCERAR

D8
8

C2
1uF

D9
9

D10
10

D11
11

D12
12

D13
13

D14
14

D15
15

D16
16

Anda mungkin juga menyukai