Diferencia entre revisiones de «Errores en Simulacion - Codewarrior 6.3»
| Línea 1: | Línea 1: | ||
| − | + | En el desarrollo de un programa, al momento de una depuración de un proyecto nos puede salir los siguientes mensajes de error: | |
==Error Fuera de Rango== | ==Error Fuera de Rango== | ||
| Línea 19: | Línea 19: | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
| − | + | ;*************************************************************************************************** | |
| + | ; Codigo de Ejemplo ... Solucion A. | ||
| + | ;*************************************************************************************************** | ||
| + | |||
| + | ; Include derivative-specific definitions | ||
| + | INCLUDE 'derivative.inc' | ||
| + | ; | ||
| + | ; export symbols | ||
| + | ABSENTRY Configurar_SP_COP | ||
| + | ; | ||
| + | ; definicion de variables | ||
| − | + | ORG Z_RAMStart | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | Contador: DS.B 1 | |
| + | Num1: DS.B 1 | ||
| + | Num2: DS.B 1 | ||
| − | + | ; code section | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ORG ROMStart | |
| − | + | ||
| − | + | Configurar_SP_COP: | |
| − | + | ||
| + | LDHX #RAMEnd+1 | ||
| + | TXS ; SP / $17FF | ||
| + | |||
| + | LDA #$42 | ||
| + | STA SOPT1 ; Se guarda en SOPT1 | ||
| + | ; COPE = 0, COPT = 1, STOPE= 0 | ||
| + | ; 0, 0, RSTOPE= 0 | ||
| + | ; BKGDPE= 1 --- Habilita el backroung debug mode | ||
| + | ; RSTPE = 0 --- Deshabilita el RESET | ||
| − | + | Configuracion_Previa: | |
| − | BSR | + | BSR Configurar_GPIO |
| − | + | BSR Configurar_RTC | |
| − | + | BRA main | |
| − | + | ||
| − | + | ; ------------------------------------------------------------------- | |
| + | Configurar_GPIO: | ||
| + | |||
| + | ;Se configura los 6 bits inferiores de PTC y los 2 bits superiores de PTE como salida | ||
| + | ;Corresponden a los leds de la tarjeta | ||
| − | + | LDA #$3F | |
| + | STA PTCDD | ||
| + | LDA #$C0 | ||
| + | STA PTEDD | ||
| − | + | LDA #$3F | |
| − | + | STA PTCD | |
| − | + | LDA #$C0 | |
| + | STA PTED | ||
| + | |||
| + | RTS | ||
| − | + | ; --------------------------------------------------------------------------- | |
| + | Configurar_RTC: | ||
| − | + | LDA #$04 | |
| + | STA SCGC2 ; Habilitamos el Clock Gate para el RTC | ||
| + | |||
| + | LDA #00 | ||
| + | STA RTCMOD ; Definimos el valor del registro modulo del RTC | ||
| + | |||
| + | LDA #%00011000 ; Configuramos el RTCSC / Reloj configurado a 1ms. Fuente reloj interna 1khz. | ||
| + | ; Interrupciones habilitadas (bit 4) | ||
| + | ; RTIF=0, RTCLKS6=0 RTCLKS5=0 | ||
| + | ; RTIE=1, RTCPS3=1, RTCPS2=0 | ||
| + | ; RTCPS1=0, RTCPS0=0 | ||
| + | STA RTCSC | ||
| + | |||
| + | RTS | ||
| − | + | main: | |
| − | + | ||
| − | + | ||
| − | + | MOV #10, Contador | |
| + | MOV #1, Num1 | ||
| + | MOV #2, Num2 | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| − | + | CLI | |
| + | |||
| + | ;************************************************************** | ||
| + | ;* RUTINAS DE INTERRUPCION * | ||
| + | ;************************************************************** | ||
| + | ;Limpiamos las banderas de interrupcion. Se escribe un 1 en la bandera RTIF | ||
| + | |||
| + | LDA RTCSC | ||
| + | ORA #%10000000 | ||
| + | STA RTCSC | ||
| + | |||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | |||
| + | RTI | ||
| + | |||
| + | ;************************************************************** | ||
| + | ;* INTERRUPT VECTORS * | ||
| + | ;************************************************************** | ||
| + | ORG $FFFE | ||
| + | DC.W Configurar_SP_COP ; Reset | ||
| − | + | ORG $FFCE | |
| − | + | DC.W Interrupcion_RTC | |
| − | + | </syntaxhighlight> | |
| − | </syntaxhighlight> | + | |
Revisión del 20:09 24 mar 2013
En el desarrollo de un programa, al momento de una depuración de un proyecto nos puede salir los siguientes mensajes de error:
Error Fuera de Rango
Si el Programa Principal es muy largo y se emplea el manejo de subrutinas a través del comando BRS (Branch Subrutine) y las mismas son colocadas al final del código del programa principal, se puede presentar el siguiente mensaje de error:
Error: Axxx: Value out of range -128...127
Esto es debido a que el comando BSR maneja un relativo, el cual permite realizar los saltos a una rutina deseada con un desplazamiento ubicado en el rango de 80 - 7F (-128 … 127), ya que el mismo puede realizar el Branch para arriba o abajo (Dependiendo el caso).
Soluciones
Se pueden establecer tres tipos de soluciones para este caso:
a. Si el Código principal es muy largo, se debe definir las subrutinas justo después de las llamadas con BSR, una vez realizada cada una de estas realizamos un BRA al código principal
;***************************************************************************************************
; Codigo de Ejemplo ... Solucion A.
;***************************************************************************************************
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
;
; export symbols
ABSENTRY Configurar_SP_COP
;
; definicion de variables
ORG Z_RAMStart
Contador: DS.B 1
Num1: DS.B 1
Num2: DS.B 1
; code section
ORG ROMStart
Configurar_SP_COP:
LDHX #RAMEnd+1
TXS ; SP / $17FF
LDA #$42
STA SOPT1 ; Se guarda en SOPT1
; COPE = 0, COPT = 1, STOPE= 0
; 0, 0, RSTOPE= 0
; BKGDPE= 1 --- Habilita el backroung debug mode
; RSTPE = 0 --- Deshabilita el RESET
Configuracion_Previa:
BSR Configurar_GPIO
BSR Configurar_RTC
BRA main
; -------------------------------------------------------------------
Configurar_GPIO:
;Se configura los 6 bits inferiores de PTC y los 2 bits superiores de PTE como salida
;Corresponden a los leds de la tarjeta
LDA #$3F
STA PTCDD
LDA #$C0
STA PTEDD
LDA #$3F
STA PTCD
LDA #$C0
STA PTED
RTS
; ---------------------------------------------------------------------------
Configurar_RTC:
LDA #$04
STA SCGC2 ; Habilitamos el Clock Gate para el RTC
LDA #00
STA RTCMOD ; Definimos el valor del registro modulo del RTC
LDA #%00011000 ; Configuramos el RTCSC / Reloj configurado a 1ms. Fuente reloj interna 1khz.
; Interrupciones habilitadas (bit 4)
; RTIF=0, RTCLKS6=0 RTCLKS5=0
; RTIE=1, RTCPS3=1, RTCPS2=0
; RTCPS1=0, RTCPS0=0
STA RTCSC
RTS
main:
MOV #10, Contador
MOV #1, Num1
MOV #2, Num2
...
...
...
CLI
;**************************************************************
;* RUTINAS DE INTERRUPCION *
;**************************************************************
;Limpiamos las banderas de interrupcion. Se escribe un 1 en la bandera RTIF
LDA RTCSC
ORA #%10000000
STA RTCSC
...
...
...
RTI
;**************************************************************
;* INTERRUPT VECTORS *
;**************************************************************
ORG $FFFE
DC.W Configurar_SP_COP ; Reset
ORG $FFCE
DC.W Interrupcion_RTC
Pantalla en blanco en el True-Time Simulator & Real-Timer Debugger
Modos de direccionamiento