Beruflich Dokumente
Kultur Dokumente
; export symbols
XDEF _Startup, main
; we export both '_Startup' and 'main' as symbols. Either can
; be referenced in the linker .prm file or from C/C++ later on
; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition
ORG $90
LEDS: DS.B 1 ;Reservamos espacio para una variable
contador llamada LEDS
; code section
MyCode: SECTION
main:
_Startup:
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
INICIALIZAR:
MOV #$0,LEDS ; Inicializamos el contador en 0.
CONFIGURAR_ADC:
MOV #$20,ADCSC1 ; Enable
continouos conversion, hardware triggered, Set channel PTA
MOV #$00,ADCCFG_MODE0 ; Set 8 bits mode
CONFIGURAR_RTC:
LDA #$00
STA RTCMOD ; Configuramos el contador en 0 ya que se
cuenta cada 0.1s
LDA #$1E ;
STA RTCSC ; Configuramos el registro RTCSC
; RTDPS = 1101, RTCLKS = 00 para
configurar el reloj del contador en 0.1s
; RTIE = 1 para activar
interrupciones
CONFIGURAR_SCI:
LDA #$00
STA SCI1C1 ; 8-bit mode. Normal operation
LDA #$2C
STA SCI1C2 ; Receiver interrupt enable. Transmitter
and receiver enable
LDA #$00
STA SCI1C3 ; Disable all errors interrupts
LDA #$1A ; This register and the SCI1BDH are used
to configure the SCI baud rate
STA SCI1BDL ; * BUSCLK
4MHz *
LDA #$00 ; * Baud rate = -------------------------
= ----------- = 9600bps *
STA SCI1BDH ; * [SBR12:SBR0]
x 16 26 x 16 *
CONFIGURAR_PUERTOS:
MOV #$FF,PTCDD ; Configuramos los pines del puerto
C como salida.
MOV #$FF,PTCD ; inicializamos los Leds del Puerto
C en 1 (Logica negada), para apagarlos.
;********************************************************************
;Rutinas de interrupciones
;********************************************************************
ISR_RTC:
LDA #$80
ORA RTCSC
STA RTCSC ; Bajamos la Bandera de interupcion de
RTC
JSR captura
STA SCI1D
BRCLR SCI1S1_TDRE,SCI1S1,*
LDA SCI1S1
;****************************************************************
;* Application Subrutines *
;****************************************************************
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG Vtpm3ovf
DC.W spurious ; TPM3 overflow
DC.W spurious ; TPM3 CH5
DC.W spurious ; TPM3 CH4
DC.W spurious ; TPM3 CH3
DC.W spurious ; TPM3 CH2
DC.W spurious ; TPM3 CH1
DC.W spurious ; TPM3 CH0
DC.W ISR_RTC ; RTC
DC.W spurious ; SCI2 Tx
DC.W spurious ; SCI2 Rx
DC.W spurious ; SCI2 Error
DC.W spurious ; Analog comparator X
DC.W spurious ; ADC
DC.W spurious ; Keyboard
DC.W spurious ; IICx Control
DC.W spurious ; SCI1 Tx
DC.W spurious ; SCI1 Rx
DC.W spurious ; SCI1 Error
DC.W spurious ; SPI1
DC.W spurious ; SPI2
DC.W spurious ; TPM2 overflow
DC.W spurious ; TPM2 CH2
DC.W spurious ; TPM2 CH1
DC.W spurious ; TPM2 CH0
DC.W spurious ; TPM1 overflow
DC.W spurious ; TPM1 CH2
DC.W spurious ; TPM1 CH1
DC.W spurious ; TPM1 CH0
DC.W spurious ; Low Voltage
DC.W spurious ; IRQ
DC.W spurious ; SWI
; DC.W _Startup ; Reset ;Se elimina Vreset esta definido wn
proyect.prn en otro sitio