.
;********************************************************************************
.MESSAGE "Rotinas das configurações ativadas."
;********************************************************************************
; sm2, se, sm1, sm0,
; 000 = idle
; 110 = standby
; 111 = standby estendido
;********************************************************************************
re_ucp_cnfg: in r16,SFIOR
cbr r16,(1<<PUD) ; 0 = habilita o pull-up
out SFIOR,r16
ret
;********************************************************************************
;
;
;
;********************************************************************************
.MESSAGE "Configurando o modo de DORMÊNCIA..."
re_dormencia:
.MESSAGE "Modo baixo consumo..."
in r16,MCUCR ; dorminh, baixo consum e ints por descida
clr r16
cbr r16, (0<<SM2)
sbr r16, (1<<SM1)
cbr r16, (0<<SM0)
out MCUCR,r16
ret
;********************************************************************************
;
;
;
;********************************************************************************
re_caoguarda: push r16
.MESSAGE "Cão de guarda 4..."
in r16,WDTCR
cbr r16,(1<<WDE)
sbr r16,(1<<WDP2)
sbr r16,(1<<WDP1)
sbr r16,(1<<WDP0)
cbr r16,(1<<WDTOE)
out WDTCR,r16
pop r16
ret
;********************************************************************************
;
;
;
;********************************************************************************
.MESSAGE "Definindo a direção e pull-up da PORTA A..."
ri_portA_cnfg: ldi r16,f_CNFG_A
sts v_DDR_A,r16
ldi r17,f_DADO_A
sts v_PORTA_A,r17
out DDRA,r16
out SAIDA_A,r17
wdr
ret
;********************************************************************************
;
;
;
;********************************************************************************
.MESSAGE "Definindo a direção e pull-up da PORTA A..."
ri_portB_cnfg: ldi r16,f_CNFG_B
sts v_DDR_B,r16
ldi r17,f_DADO_B
sts v_PORTA_B,r17
out DDRB,r16
out SAIDA_B,r17
wdr
ret
;********************************************************************************
;
;
;
;********************************************************************************
.MESSAGE "Definindo a direção e pull-up da PORTA C..."
ri_portC_cnfg: ldi r16,f_CNFG_C
sts v_DDR_C,r16
ldi r17,f_DADO_C
sts v_PORTA_C,r17
out DDRC,r16
out SAIDA_C,r17
wdr
ret
;********************************************************************************
;
;
;
;********************************************************************************
;* PC5 (TDI) LCD_RS *
;* PC4 (TDO) LCD_EN *
;* PC3 (TMS) SER_dado *
;* PC2 (TCK) SER_clk *
;* *
;* 1 = saída e 0 = entrada *
;********************************************************************************
.MESSAGE "Configurando os pinos de E/S do uC para o LCD..."
.MESSAGE "Definido o LCD paralelo..."
re_cpu_lcdcnfg: lds r16,v_DDR_C
andi r16,masc_E_2345 ; 1 = saída e 0 = entrada
ori r16,masc_Ou_2345
sts v_DDR_C,r16
out DDRC,r16
ret
;********************************************************************************
;
;
;
;********************************************************************************
.MESSAGE "Ativando a INTERRUPÇÃO EXTERNA 1."
re_intext1_cnfg: push r16
.MESSAGE "Porta D / 7 como entrada com resistor pull-up."
lds r16,v_DDR_D ; config. o pino como entrada.
andi r16,masc_E_3 ; PD 3 = 0 = Entrada
sts v_DDR_D,r16
;
lds r17,v_PORTA_D
ori r17,masc_Ou_3
sts v_PORTA_D,r17
;
out DDRD,r16
out PORTD,r17
;
lds r16,v_GICR ; configura a interrupção.
ori r16,masc_Ou_7 ; INT 1 = bit 7 = 1 = habilita
sts v_GICR,r16
out GICR,r16
pop r16
ret
;********************************************************************************
;
;
;
;********************************************************************************
;* 3 2 1 0
;* ISC11 ISC10 ISC01 ISC00 MCUCR
.MESSAGE "Configurando o nível do sinal de excetação da INT. EXT."
re_intext1_nvl: push r16
.IFDEF __nvl_baixo_1__
.MESSAGE "POR NÍVEL BAIXO."
ldi r16,v_MCUCR
andi r16,masc_E_23
sts v_MCUCR,r16
out MCUCR,r16
pop r16
ret
.ELIF defined __nvl_altern_1__
.MESSAGE "POR ALTERAÇÃO DO NÍVEL."
ldi r16,v_MCUCR
andi r16,masc_E_23
ori r16,masc_Ou_2
sts VAR_MCUCR,r16
out MCUCR,r16
pop r16
ret
.ELIF defined __borda_desc_1__
.MESSAGE "POR BORDA DE DESCIDA."
ldi r16,v_MCUCR
andi r16,masc_E_23
ori r16,masc_Ou_3
sts v_MCUCR,r16
out MCUCR,r16
pop r16
ret
.ELIF defined __borda_subi_1__
.MESSAGE "POR BORDA DE SUBIDA."
ldi r16,v_MCUCR
andi r16,masc_E_23
ori r16,masc_Ou_23
sts v_MCUCR,r16
out MCUCR,r16
pop r16
ret
.ELSE
.WARNNING "Não foi configurado o nível da INT. EXT. 1 - forçada POR BORDA DE DESCIDA."
ldi r16,v_MCUCR
andi r16,masc_E_23
ori r16,masc_Ou_3
sts v_MCUCR,r16
out MCUCR,r16
pop r16
ret
.ENDIF
;********************************************************************************
.
Nenhum comentário:
Postar um comentário