Autor Tema: quien me puede passar este asm a hex  (Leído 3919 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado nordestenica

  • PIC16
  • ***
  • Mensajes: 215
quien me puede passar este asm a hex
« en: 26 de Marzo de 2004, 03:22:00 »
pues esso estoi intentando passar este fichero asm a hex e lo e intentado de todas formas con el proteus directamente con el mpasm e me da siempre el mismo error que le falta el fichero no se quantos.cod e no consigo passarlo

aver si alguiem me lo puede passar e me explica un poco como lo ago es que tengo otros e me gustaria probarlos






; ------------------------------------------------------------------------
; FILE     : LCD_CNTR.ASM                                                *
; CONTENTS : Simple low-cost 7-digit counter using a PIC16F84            *
; COPYRIGHT: Peter Halicky  OM3CPH                                       *
; AUTHOR   : Peter Halicky  OM3CPH & Peter Halicky Jr., OM2APH           *
; PCB      : Tibor Madarasz OM2ATM                                       *
;--------------------------------------------------------------------------
; E-Mail: halicky@cepoe.minv.sk or om3cph@oe3xbs.aut.eu
;         peto-h@writeme.com  or om2aph@om0pbm.svk.eu
;
; Bratislava, Slovakia, December 1998
;
;--------------------------------------------------------------------------
; This is 7-digit counter counting up to 35 MHz. The decimal point
; is after MHz digit.
;
; Hardware is very simple:
;
; It contains     : PIC 16F84
;                   1 NPN low power HF Si transistor,
;                   16 character (2x8) in 1 Line LCD display,
;                   Xtal 1..10 MHz,
;                   some resistors, capacitors and 2 Si switching diodes...
;                   (see schematic in lcd_cntr.pcx)
; Note:
; LCD display is 16 character in 1 line LCD display PVC160101PTN which
; seems to be compatible with TWO LINES HITACHI LCD display, exept
; that it has only 8 characters in 1 line.
;
; The counter uses internal prescaler of PIC as low byte of counter,
; TMR0 as middle byte and some register as high byte of counter.
;
; Some ideas were taken from "Simple low-cost digital frequency meter
;                             using a PIC 16C54" (frqmeter.asm)
;                             written by James Hutchby, MadLab Ltd. 1996
; LCD interfacing was taken from AN587 and mainly from LCD.ASM written
; by Peter Ouwehand.
; ------------------------------------------------------------------------
;
; This software is free for private usage. It was created for HAM radio
; community members. Commercial exploatation is allowed only with permission
; of authors.
;
; ------------------------------------------------------------------------
;
; The measuring period is 100 000 us.
; Procesor cycle is T = 4/fx [us,MHz], fx is Xtal frequency
;
; Number of procesor cycles per measuring period:
;
;        N = 100 000/T procesor cycles
;        N = fx x 100 000/4 = 25 000 x fx
;
;        The main steps of measuring period:
;
;        1. decode 3-byte value into 7 decimal numbers,
;        2. decode decimal value of digit to chars,
;        3. set decimal point if needed,
;        4. output to PORTB (LCD),
;        5. start measurement,
;        6. test TMR0 overflow bite, if YES increase TimerH,
;        7. goto 5 until measuring period is done,
;        8. stop measurement,
;        9. shift out precounter content,
;       10. goto 1
;
; ------------------------------------------------------------------------
;
; Total timing formula:
;
; N = 25 000 x fosc[MHz]
;
; Example:  fosc = 4 MHz
;
; N = 25 000 x 4 = 100 000
; N = 25 000 x fx = ((9*T1+4)*T2+4)*T3+1+(9+X)*T4+6
;
; ------------------------------------------------------------------------

   include <p16c84.inc>

; ------------------------------------------------------------------------

Index       equ        0Ch         ; dummy register
Count       equ        0Dh         ; inkremental register
Help        equ        0Eh         ; dummy register

LED0        equ        0Fh
LED1        equ       010h
LED2        equ       011h
LED3        equ       012h
LED4        equ       013h
LED5        equ       014h
LED6        equ       015h

LCD_TEMP    equ       016h         ; LCD subroutines internal use

TimerH      equ       017h         ; the highest byte of SW counter

LowB        equ       018h         ; low byte of resulted frequency
MidB        equ       019h         ; middle byte of resulted frequency
HigB        equ       01Ah         ; high byte of resulted frequency

TEMP        equ       01Bh         ; temporary register
HIndex      equ       01Ch         ; index register
LEDIndex    equ       01Dh         ; LED pointer

R1          equ       01Eh         ; Timing counters
R2          equ       01Fh
R3          equ       020h

; ------------------------------------------------------------------------
; LCD variables
; ------------------------------------------------------------------------

;FREQ       EQU      .4196         ; Xtal frequency in kHz
DELAY15     EQU      .19           ; (HIGH((4000/FREQ)*15000/770))+1

LINE0       equ       0
LINE1       equ       040h
                                   ; PORTA bits
E       equ         2         ; LCD Enable control line
R_W       equ         1         ; LCD Read/Write control line
RS       equ         0         ; LCD Register-Select control line

; ------------------------------------------------------------------------
                                   ; timing loop values
                                   ; must be from 1 to 255!!!
T1          equ       .255         ; first timing loop
T2          equ       .9           ; second timing loop
T3          equ       .5           ; third timing loop
T4          equ       .149         ; last timing loop
                                   ; values for 4 194 kHz Xtal
; ------------------------------------------------------------------------
            org        0

Start
            clrf       STATUS           ; Do initialization, Select bank 0
       clrf       INTCON           ; Clear int-flags, Disable interrupts
       clrf       PCLATH           ; Keep in lower 2KByte
       clrf       PORTA            ; ALL PORT output should output Low.
       clrf       PORTB

            clrf       Index
            clrf       LEDIndex

            clrf       LED0
            clrf       LED1
            clrf       LED2
            clrf       LED3
            clrf       LED4
            clrf       LED5
            clrf       LED6

            clrf       LowB
            clrf       MidB
            clrf       HigB

            bsf        STATUS,RP0

            movlw      b"00010000" ; RA0..RA3 outputs
            movwf      TRISA       ; RA4 input

            movlw      b"00000000" ; RB0..RB7 outputs
            movwf      TRISB
          bsf          OPTION_REG,NOT_RBPU

            clrwdt                 ; Disable PORTB pull-ups
            movlw      b"10100111" ; Prescaler -> TMR0,
            movwf      OPTION_REG  ; 1:256, rising edge
            bcf        STATUS,RP0  ;
                                   ; Initilize LC-Display Module
                       ; Busy-flag is not yet valid
       clrf       PORTA       ; ALL PORT output should output Low.

            movlw      DELAY15     ; Wait for 15ms for LCD to get powered up
            movwf      R1
            clrf       R2
LCycle
            decfsz     R2,F
            goto       LCycle      ; 3*256
            decfsz     R1,F        ; 3*256+1
            goto       LCycle      ;(3*256+2)*R1=770*R1 in procesor cycles

          movlw      B"00111000" ; 8-bit-interface, 2-lines
       call       PutCMD

       movlw      B"00001000" ; disp.off, curs.off, no-blink
       call       PutCMD

       movlw      1           ; LCD clear
       call       PutCMD

            movlw      B"00001100" ; disp.on, curs.off
       call       PutCMD

       movlw      B"00000110" ; auto-inc (shift-cursor)
       call       PutCMD

            goto       Go

;************************************************************************
; LCD Module Subroutines
;************************************************************************
; Busy: Returns when LCD busy-flag is inactive
;
; PORTA returns as RA0..RA2 output, RA3,RA4 input
; PORTB returns as full output
;========================================================================
Busy
       bsf          STATUS,RP0  ; Select Register page 1

       movlw      0FFh       ; Set PORTB for input
       movwf      TRISB

            movlw      b"00011000" ; PORTA should be set RA0..RA2 output
            movwf      TRISA       ; RA3,RA4 input

       bcf        STATUS,RP0  ; Select Register page 0


       bcf          PORTA,RS    ; Set LCD for command mode
       bsf          PORTA,R_W   ; Setup to read busy flag
       bsf          PORTA,E      ; LCD E-line High

       movf       PORTB,W      ; Read busy flag + DDram address

       bcf          PORTA,E      ; LCD E-line Low
       andlw      080h        ; Check Busy flag, High = Busy
       btfss      STATUS,Z
       goto       Busy

            bcf        PORTA,R_W

       bsf          STATUS,RP0  ; Select Register page 1

       movlw      0
       movwf      TRISB      ; Set PORTB for output

       bcf          STATUS,RP0  ; Select Register page 0
       return

;========================================================================
; PUTCHAR Sends character to LCD, Required character must be in W
;========================================================================
PutCHAR
       movwf   LCD_TEMP   ; Character to be sent is from W saved
       call   Busy      ; Wait for LCD to be ready
                                   ; Busy routine sets PORTA&PORTB adequately
       bcf           PORTA,R_W  ; Set LCD in read mode
       bsf           PORTA,RS   ; Set LCD in data mode
       bsf           PORTA,E      ; LCD E-line High
       movf   LCD_TEMP,W ; Restore character into W
       movwf   PORTB      ; Send data to LCD
       bcf           PORTA,E      ; LCD E-line Low
       return

;========================================================================
; PutCMD Sends command to LCD, Required command must be in W
;========================================================================
PutCMD
       movwf   LCD_TEMP   ; Command to be sent is from W saved

       call   Busy      ; Wait for LCD to be ready
                                   ; Busy routine sets PORTA&PORTB adequately
       bcf           PORTA,R_W  ; Set LCD in read mode
       bcf           PORTA,RS   ; Set LCD in command mode
       bsf           PORTA,E    ; LCD E-line High
       movf   LCD_TEMP,W
       movwf   PORTB      ; Send data to LCD
       bcf           PORTA,E      ; LCD E-line Low
       return

;************************************************************************
; End of LCD Module Subroutines
;************************************************************************
; Numeric routines
;------------------------------------------------------------------------
; 3 byte substraction of the constant from the table which sets carry if
; result is negative
;------------------------------------------------------------------------

Subc24      clrf       TEMP        ; it will TEMPorary save C
            movf       Index,W     ; pointer to low byte of constant
            movwf      HIndex      ; W -> HIndex
            call       DecTable    ; W returned with low byte of constant
            bsf        STATUS,C    ; set C
            subwf      LowB,F      ; LowB - W -> LowB
                                   ; if underflow -> C=0
            btfsc      STATUS,C
            goto       Step1
            bsf        STATUS,C
            movlw      1
            subwf      MidB,F      ; decrement MidB
                                   ; if underflow -> C=0
            btfsc      STATUS,C
            goto       Step1

            bsf        STATUS,C
            movlw      1
            subwf      HigB,F      ; decrement HigB
            btfsc      STATUS,C    ; if underflow -> C=0
            goto       Step1
            bsf        TEMP,C      ; set C

Step1       decf       HIndex,F
            movf       HIndex,W    ; pointer to middle byte of const
            call       DecTable
            bsf        STATUS,C
            subwf      MidB,F      ; MidB - W -> MidB
            btfsc      STATUS,C    ; if underflow -> C=0
            goto       Step2
            bsf        STATUS,C
            movlw      1
            subwf      HigB,1      ; decrement HigB
            btfsc      STATUS,C    ; if underflow -> C=0
            goto       Step2
            bsf        TEMP,C      ; set C

Step2       decf       HIndex,F
            movf       HIndex,W    ; pointer to middle byte of constatnt
            call       DecTable
            bsf        STATUS,C
            subwf      HigB,F      ; HigB - W -> HigB
            btfsc      STATUS,C    ; if underflow -> C=0
            goto       ClearCF
            bsf        STATUS,C
            goto       SubEnd
ClearCF     rrf        TEMP,C      ; C -> STATUS
SubEnd      retlw      0

; ------------------------------------------------------------------------
; 3 byte addition of the constant from the table which sets carry if
; result overflows
; ------------------------------------------------------------------------

Addc24      clrf       TEMP        ; register for TEMPorary storage of C
            movf       Index,W     ; pointer to lower byte of const into W
            movwf      HIndex      ; save it into HIndex
            call       DecTable    ; W contains low byte of const
            bcf        STATUS,C    ; clear C
            addwf      LowB,1      ; W + LowB -> LowB
            btfss      STATUS,C    ; test overflow
            goto       Add2
            bcf        STATUS,C    ; clear C
            movlw      1
            addwf      MidB,F      ; increment MidB
            btfss      STATUS,C
            goto       Add2
            bcf        STATUS,C
            movlw      1
            addwf      HigB,F      ; increment HigB
            btfss      STATUS,C    ; test overflow
            goto       Add2
            bsf        TEMP,C      ; store C
Add2        decf       HIndex,F    ; pointer to middle byte into W
            movf       HIndex,W
            call       DecTable
            bcf        STATUS,C
            addwf      MidB,1      ; W + MidB -> MidB
            btfss      STATUS,C
            goto       Add3
            bcf        STATUS,C    ; clear C
            movlw      1
            addwf      HigB,1      ; increment HigB
            btfss      STATUS,C
            goto       Add3
            bsf        TEMP,C
Add3        decf       HIndex,F    ; pointer to higher byte into W
            movf       HIndex,W
            call       DecTable
            bsf        STATUS,C
            addwf      HigB,F      ; W + HigB -> HigB,
            btfss      STATUS,C
            goto       ClarCF
            bsf        STATUS,C
            goto       AddEnd
ClarCF      rrf        TEMP,C      ; C -> STATUS
AddEnd      retlw      0

;------------------------------------------------------------------------
; Tables for 3 byte constants
;------------------------------------------------------------------------
; Table of decades
;------------------------------------------------------------------------

DecTable    addwf      PCL,F       ; W + PCL -> PCL
            retlw      0           ; 10
            retlw      0           ;
            retlw      0Ah         ;

            retlw      0           ; 100
            retlw      0           ;
            retlw      064h        ;

            retlw      0           ; 1 000
            retlw      03h         ;
            retlw      0E8h        ;

            retlw      0           ; 10 000
            retlw      027h        ;
            retlw      010h        ;

            retlw      01h         ; 100 000
            retlw      086h        ;
            retlw      0A0h        ;

            retlw      0Fh         ; 1 000 000
            retlw      042h        ;
            retlw      040h        ;

;------------------------------------------------------------------------
; Table for RF shift - it is needed in the case of digiscale
; Example: 10.7 MHz is set as 1 070 000 = 10 53 B0 hex
; Note: direct definition using compiler directive is possible too...
;------------------------------------------------------------------------

MFTable     addwf      PCL,F
            retlw      010h
            retlw      053h
            retlw      0B0h

;************************************************************************
; Entry point for main cycle
;************************************************************************

;------------------------------------------------------------------------
; Routine for the conversion of 3 byte number into 7 decimal numbers
;------------------------------------------------------------------------

Go
            movlw      6*3-1       ; pointer to dec. table
            movwf      Index       ; 6*3-1 -> Index

            movlw      9           ; maximum of substractions
            movwf      Count       ; 9 -> Count

            clrf       Help

            movlw      6
            movwf      LEDIndex

Divide      call       Subc24      ; substract untill result is negative,
            btfsc      STATUS,C    ; add last substracted number
            goto       Add24       ; next digit
            incf       Help,F
            decf       Count,F
            btfss      STATUS,Z
            goto       Divide
            movlw      3
            subwf      Index,F
            goto       Next

Add24       call       Addc24
            movlw      03h
            subwf      Index,F

Next        movlw      9
            movwf      Count
            movlw      LED1        ; LED1 -> W
            addwf      LEDIndex,W  ; LED1 + LEDIndex -> W
            movwf      TEMP
            decf       TEMP,F      ; LEDIndex+LED1-1 -> TEMP
            movf       TEMP,W

            movwf      FSR         ; W -> FSR
            movf       Help,W      ; Help -> W
            clrf       Help        ; save result at LEDx
            movwf      INDF        ; W -> LED(6..1)
            decf       LEDIndex,F

            movlw      1
            addwf      Index,W
            btfss      STATUS,Z
            goto       Divide

            movf       LowB,W
            movwf      LED0        ; the rest -> LED0

;-------------------------------------------------------------------------
; registers LED0..LED6 are filled with values - ready to be displayed
;-------------------------------------------------------------------------

            movlw      6
            movwf      LEDIndex

            movlw      LINE0
          iorlw      080h        ; Position cursor leftmost on first line
       call       PutCMD

LEDCycle
            movlw      LED0        ; LED0 -> W
            addwf      LEDIndex,W  ; LED1 + LEDIndex -> W

            movwf      FSR         ; W -> FSR
            movf       INDF,W      ; LED(0..6) -> W

            iorlw      030h
            call       PutCHAR      ; Display character

            movlw      5           ; test for decimal point
            bsf        STATUS,Z
            subwf      LEDIndex,W
            btfss      STATUS,Z
            goto       NoDot
            movlw      "."         ; this can be " " or "," ......
            call       PutCHAR      ; Display character
NoDot
            decfsz     LEDIndex,F
            goto       LEDCycle    ; continue with next number

            movlw      LED0        ; LED0 -> W
            addwf      LEDIndex,W  ; LED0 + LEDIndex -> W

            movwf      FSR         ; W -> FSR
            movf       INDF,W      ; [FSR] -> W

            iorlw      030h
            call       PutCHAR      ; Display character

            movlw      LINE1       ; continue at right half of display
        iorlw      080h        ; Function set
       call       PutCMD      ; Position cursor leftmost on first line

            movlw      " "
            call       PutCHAR      ; Display character
            movlw      "M"
            call       PutCHAR      ; Display character
            movlw      "H"
            call       PutCHAR      ; Display character
            movlw      "z"
            call       PutCHAR      ; Display character

            movlw      LINE0
       iorlw      080h        ; Function set
       call       PutCMD

;-------------------------------------------------------------------------
; It is time to prepare new measuring cycle
;-------------------------------------------------------------------------

            clrf       TimerH
            clrf       TMR0
            nop                    ; it is SUGGESTED...
            nop

            clrf       LEDIndex

            movlw      T1          ; set initial counter values
            movwf      R1
            movlw      T2
            movwf      R2
            movlw      T3
            movwf      R3

            clrf       INTCON      ; global INT disable, TMR0 INT disable
                                   ; clear TMR0 overflow bite

; ------------------------------------------------------------------------
; Start measurement:  RA3 + RA4 set input
; ------------------------------------------------------------------------

            movlw      b"00010000" ; all ports set L, RA4 set H
            movwf      PORTA

            bsf        STATUS,RP0
            movlw      b"00011111" ; RA0..RA4 input
            movwf      TRISA
            bcf        STATUS,RP0

; -------------------------------------------------------------------------
; It is opened now...
; -------------------------------------------------------------------------
Cycle
            btfss      INTCON,2 ; 1   Test for TMR0 overflow
            goto       Nothing  ; 3
            incf       TimerH,F ; 3
            bcf        INTCON,2 ; 4
            goto       Nxt      ; 6
Nothing
            nop                 ; 4
            nop                 ; 5
            nop                 ; 6
Nxt
            decfsz     R1,F     ; 7
            goto       Cycle    ; 9
            movlw      T1       ; 9*T1

            movwf      R1       ; 9*T1+1
            decfsz     R2,F     ; 9*T1+2
            goto       Cycle    ; 9*T1+4
            movlw      T2       ;(9*T1+4)*T2

            movwf      R2       ;(9*T1+4)*T2+1
            decfsz     R3,F     ;(9*T1+4)*T2+2
            goto       Cycle    ;(9*T1+4)*T2+4
                                ;((9*T1+4)*T2+4)*T3-1

; ------------------------------------------------------------------------
; Short fine tuning delay - enable it if needed.....
; ------------------------------------------------------------------------
;            movlw      .1
;            movwf      Help
;CCC
;            decfsz     Help,F
;            goto       CCC

            nop                 ;((9*T1+4)*T2+4)*T3

; ------------------------------------------------------------------------
; Final test for TMR0 overflow
; ------------------------------------------------------------------------

            movlw      T4       ;((9*T1+4)*T2+4)*T3
            movwf      Help     ;((9*T1+4)*T2+4)*T3+1
Cycle2
            btfss      INTCON,2   ; 1
            goto       Not2Do     ; 3
            incf       TimerH,F   ; 3
            bcf        INTCON,2   ; 4
            goto       Nx         ; 6
Not2Do
            nop                   ; 4
            nop                   ; 5
            nop                   ; 6
Nx
;           nop                   ; fine tuning nops
;           nop
;           nop

            decfsz     Help,F     ; 7+X
            goto       Cycle2     ; 9+X

; ------------------------------------------------------------------------
; Stop the measurement
; ------------------------------------------------------------------------

            clrw                   ; (9+X)*T4
            movwf      PORTB       ; 1
            movlw      b"00010000" ; 2   RA0..RA3 = 0
            movwf      PORTA       ; 3   W -> PORTA


            bsf        STATUS,RP0  ; 4
            movlw      b"00010111" ; 5   RA3 output
            movwf      TRISA       ; 6   RA0..RA2,RA4 input
            bcf        STATUS,RP0  ;

; ------------------------------------------------------------------------
; Analyse precounter and store counted value in registers
; ------------------------------------------------------------------------

            movf       TMR0,W
            movwf      MidB        ; TMR0 -> MidB

            movf       TimerH,W
            movwf      HigB        ; TimerH -> HigB

            clrf       TEMP
CountIt
            incf       TEMP,F
            bsf        PORTA,3     ; _| false impulz
            bcf        PORTA,3     ;    |_

            bcf        INTCON,2
            movf       TMR0,W      ; actual TMR0 -> W
            bcf        STATUS,Z
            subwf      MidB,W
            btfsc      STATUS,Z
            goto       CountIt
            incf       TEMP,F
            comf       TEMP,F
            incf       TEMP,F
            incf       TEMP,W

            movwf      LowB

; ------------------------------------------------------------------------

            goto       Go          ;  start new cycle

; ------------------------------------------------------------------------

            end

Desconectado Elena2000

  • PIC24F
  • *****
  • Mensajes: 722
RE: quien me puede passar este asm a hex
« Respuesta #1 en: 26 de Marzo de 2004, 03:50:00 »
Hola!

Lo acabo de pasar con el MPLAB y no me ha dado ningún error.

¿Donde te envío el hex? te lo paso por privado, vale?

Desconectado nordestenica

  • PIC16
  • ***
  • Mensajes: 215
RE: quien me puede passar este asm a hex
« Respuesta #2 en: 26 de Marzo de 2004, 07:45:00 »
gracias elena me as sacado de un apuro


haora por favor dime que version del mplab as usado e como lo as configurado es que por mas que intente no consigo

por lo que me creo los errores que me da no deberiam aparecer ya que teniendo el asm no  te ace falta los demas o sea el cod el err e el lst no son nessesarios ya que el proprio mpasm los genera
es esto verdad no

porque si intento passar un asm que contenga los demas ficheros o sea el asm el cod el err e el lst me lo passa bien a hex sin ningun tipo de problemas

o sera problema de xp es que estoy usando el xp

no se me estoy volviendo loco

Desconectado Elena2000

  • PIC24F
  • *****
  • Mensajes: 722
RE: quien me puede passar este asm a hex
« Respuesta #3 en: 30 de Marzo de 2004, 03:38:00 »
HOLA!

A ver, yo tengo el MPLAB 6.40. Cuando compilé tu asm, me salieron muchísimos "warnings", pero a esos no se les hace caso; además los queité todos porque eran debidos a que no estaban las columnas del fichero bien tabuladas, una bobada. En cuanto al include que lleva tu código, tampoco da error porque como bien dices el MPLAB lo lleva en sus librerías.

A ver, una pregunta: estás usando Windows XP para correr el MPLAB? en ese caso mira a ver si tienes instalado el service pack 2 como mínimo, porque es posible que ese sea tu problema.

Me cuentas, vale? suerte!!


 

anything