COMPILAR PROGRAMA ASM CON GPASM Y PROGRAMARLO CON PICKIT2

Bueno a los que todavia nos sigue gustando programar en ensamblador y en entorno bajo Linux va dirigido este post.

En el post anterior creabamos un programa en ensamblador con MPlabx y lo compilabamos para luego programar mediante el comando pk2cmd y Pickit2, bueno pues en este post lo que hacemos es quitarnos del programa Mplabx y directamente con la comando gpasm compilamos ese programa anterior haciendo solo una ligera modificacion, en la forma de escribir el fichero de inclusion y la definicion del pic.

Decir que para compilar con gpasm, lo que hize fue compilar la nueva version de gputil y que si el sistema operativo que esta utlizando es Puppy Linux nos la podemos bajar de:

gputils-1.5.0-i486.pet

Congiendo el programa asm del post anterior en:

https://misterelectronico.wordpress.com/2017/04/16/programar-pic-bajo-linux-con-mplabx-pickit2-y-comando-pk2cmd/

Y cambiando solamente la dos primeras lineas de definicion del Pic, quedaria el programa como se ve.

**************************************************************************************

; Solo he modificado las dos siguientes lineas el resto queda igual.

processor p18f4550
include “p18f4550.inc”

; CONFIG1L
CONFIG  PLLDIV = 1            ; PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
CONFIG  CPUDIV = OSC1_PLL2    ; System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
CONFIG  USBDIV = 1            ; USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)
; CONFIG1H
CONFIG  FOSC = INTOSCIO_EC    ; Oscillator Selection bits (Internal oscillator, port function on RA6, EC used by USB (INTIO))
CONFIG  FCMEN = OFF           ; Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
CONFIG  IESO = OFF            ; Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

; CONFIG2L
CONFIG  PWRT = OFF            ; Power-up Timer Enable bit (PWRT disabled)
CONFIG  BOR = OFF             ; Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)
CONFIG  BORV = 3              ; Brown-out Reset Voltage bits (Minimum setting)
CONFIG  VREGEN = ON           ; USB Voltage Regulator Enable bit (USB voltage regulator enabled)

; CONFIG2H
CONFIG  WDT = OFF             ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
CONFIG  WDTPS = 32768         ; Watchdog Timer Postscale Select bits (1:32768)

; CONFIG3H
CONFIG  CCP2MX = ON           ; CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
CONFIG  PBADEN = ON           ; PORTB A/D Enable bit (PORTB pins are configured as analog input channels on Reset)
CONFIG  LPT1OSC = OFF         ; Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
CONFIG  MCLRE = OFF           ; MCLR Pin Enable bit (RE3 input pin enabled; MCLR pin disabled)

; CONFIG4L
CONFIG  STVREN = OFF          ; Stack Full/Underflow Reset Enable bit (Stack full/underflow will not cause Reset)
CONFIG  LVP = OFF             ; Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
CONFIG  ICPRT = OFF           ; Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
CONFIG  XINST = OFF           ; Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

; CONFIG5L
CONFIG  CP0 = OFF             ; Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
CONFIG  CP1 = OFF             ; Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
CONFIG  CP2 = OFF             ; Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
CONFIG  CP3 = OFF             ; Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

; CONFIG5H
CONFIG  CPB = OFF             ; Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
CONFIG  CPD = OFF             ; Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

; CONFIG6L
CONFIG  WRT0 = OFF            ; Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
CONFIG  WRT1 = OFF            ; Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
CONFIG  WRT2 = OFF            ; Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
CONFIG  WRT3 = OFF            ; Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

; CONFIG6H
CONFIG  WRTC = OFF            ; Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
CONFIG  WRTB = OFF            ; Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
CONFIG  WRTD = OFF            ; Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

; CONFIG7L
CONFIG  EBTR0 = OFF           ; Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
CONFIG  EBTR1 = OFF           ; Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
CONFIG  EBTR2 = OFF           ; Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
CONFIG  EBTR3 = OFF           ; Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

; CONFIG7H
CONFIG  EBTRB = OFF           ; Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

org 00h
goto star

star
org 60h

movlw 0ffh
movwf TRISB
movwf TRISA
movwf TRISC

clrf PORTC
clrf LATC

movlw 0h
movwf TRISC        ; HACE RB0 A RB3 SALIDAS Y RB4 A RB7 SAIDAS.

luces
movlw 0ffh
movwf PORTC
call retardo

movlw 0h
movwf PORTC
call retardo

goto luces

retardo
movlw 0ffh
movwf 20h
movwf 21h
movlw 01h
movwf 22h
loop
decfsz 20
goto loop
decfsz 21
goto loop
decfsz 22
goto loop
return
end

**********************************   FIN DE CODIGO *******************************

Bueno si salvamos este archivo por ejemplo   eje01.asm  , el compilarlo es tan sencillo como :

   gpasm eje01.asm

Y listo nos encontraremos un archivo  eje01.hex   que es con el que programaremos el pic mediante  el pickit2.

Para hacerlo seguiremos los mismos pasos que en el post anterior:

https://misterelectronico.wordpress.com/2017/04/16/programar-pic-bajo-linux-con-mplabx-pickit2-y-comando-pk2cmd/

Espero sea util …. un Saludo.

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s