Você está na página 1de 2

Se tiene un Sistema que lee un colorimetro en un puerto de un

microcontrolador, proporcionando colores: Negro, Rojo, Azul, Amarillo y


Blanco.

Se pide disear un programa que lea el colorimetro y que encienda un led


indicando el color correspondiente leido.

Consideraciones:

Color Dato ledo EN HEXA


Negro 00
Rojo De 01 a 55
Azul De 56 a AB
Amarillo De AC a FE
Blanco FF

Configuraciones de puertos:

DDRA: como entrada (00)

DDRB, 5 bits como salida( 1F )

PB4 PB3 PB2 PB1 PB0


Negr Roj Azul Amarillo Blanc Dat
o o o o
0 1 1 1 1 0F
1 0 1 1 1 17
1 1 0 1 1 1B
1 1 1 0 1 1D
1 1 1 1 0 1E

;*****************************************************************
;* This stationery serves as the framework for a *
;* user application (single file, absolute assembly application) *
;* For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of the *
;* Freescale CodeWarrior for the HC12 Program directory *
;*****************************************************************

; export symbols
XDEF Entry ; export 'Entry' symbol
ABSENTRY Entry ; for absolute assembly: mark this as
application entry point

; Include derivative-specific definitions


INCLUDE 'derivative.inc'

ROMStart EQU $4000 ; absolute address to place my code/constant data


; variable/data section

ORG $1000
; Insert here your data definition.

; code section
ORG ROMStart
Entry:

LDS #RAMEnd+1 ; initialize the stack pointer


LDAA #$00
STAA DDRA
LDAA #$1F
STAA DDRB

Inicio:
LDAA PORTA
CMPA #$ 00
LBEQ ActivarNegro
CMPA #$FF
LBEQ ActivarBlanco
CMPA #$55
LBLE ActivarRojo
CMPA #AB
LBLE ActivarAzul
LDAA #$1D
STAA PORTB
LBRA Inicio
ActivarNegro:
LDAA #$0f
STAA PORTB
LBRA Inicio
ActivarBlanco:
LDAA #$1E
STAA PORTB
LBRA Inicio
ActivarRojo:
LDAA #$17
STAA PORTB
LBRA Inicio
ActivarAzul:
LDAA #$1B
STAA PORTB
LBRA Inicio
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFE
DC.W Entry ; Reset Vector

Você também pode gostar