by Luan
Posted on 19 April 2020, 15:10
In this article I expose how to setup environment to build and deploy projects for PIC16F15376.
In this article I expose how to setup environment to build and deploy projects for PIC16F15376.

This MPLAB Xpress board showcases the PIC16F15376 MCU. A member of an 8-bit product family that can leverage its eXtreme Low-Power (XLP) technology and a host of Core Independent Peripherals to be perfectly suited for a wide range of low-power applications. This device features PWMs, multiple communication interfaces, an on-chip temperature sensor and memory features like Memory Access Partition (MAP) and Device Information Area (DIA) which support customers in data protection and bootloader applications. ( Microchip )
To generate de .HEX files that are burned in PIC I used the GPUTILS:https://gputils.sourceforge.io/.
GPUTILS is a collection of tools for the Microchip ™ PIC microcontrollers. It includes gpasm, gplink, and gplib. It’s distributed under the terms of the GNU Public License. There are other GNU PIC tools available such as gpsim, a gputils compatible simulator.
The following procedure can be used to install GPUTILS:
$ svn checkout svn://svn.code.sf.net/p/gputils/code/trunk .cd gputils
make
make installMake install must be executed as superuser
gpasm -vTo test the installation a simple code was developed. The code is just a simple blink in a RGB LED. The RGB led is of common cathode type and connected to pins  RB0, RB1 and RB2 of PIC. The project can be downloaded in https://github.com/luanfrj/pic16f15376-blink 
The used code is shown:
;-------------------------------------------------------------------
;                           BLINK
;-------------------------------------------------------------------
;AUTHOR: LUAN FERREIRA REIS DE JESUS       LAST REVISION: 20/04/2020
;V 1.0.0
;-------------------------------------------------------------------
;                        DESCRIPTION
;-------------------------------------------------------------------
; Simple code to bink a RGB LED
;-------------------------------------------------------------------
;                     DEFINITION FILES
;-------------------------------------------------------------------
#INCLUDE <p16f15376.inc>
;-------------------------------------------------------------------
;                   DEVICE CONFIGURATION
;-------------------------------------------------------------------
    __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32   ; Turn off external oscilator and set internal oscilator to 32 MHz
    __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_ON            ; Enable Master Clear and Powerup Timer
    __CONFIG _CONFIG3, _WDTE_OFF                        ; Turn off the watchdog timmer
    __CONFIG _CONFIG4, _LVP_ON                          ; Low voltage programming on
;-------------------------------------------------------------------
;                        VARIABLES
;-------------------------------------------------------------------
    CBLOCK 0X20
        DELAYTEMP2
        DELAYTEMP
        SysWaitTempMS
        SysWaitTempMS_H
    ENDC
;-------------------------------------------------------------------
;                        RESET VECTOR
;-------------------------------------------------------------------
    ORG     0x0000          ; Initial Address
    GOTO    INICIO
;-------------------------------------------------------------------
;                        SUBSOUTINES
;-------------------------------------------------------------------
DELAY_MS
    INCF    SysWaitTempMS_H, 1
DMS_START
    MOVLW   D'14'
    MOVWF   DELAYTEMP2
DMS_OUTER
    MOVLW   D'189'
    MOVWF   DELAYTEMP
DMS_INNER
    DECFSZ  DELAYTEMP, 1
    GOTO    DMS_INNER
    DECFSZ  DELAYTEMP2, 1
    GOTO    DMS_OUTER
    DECFSZ  SysWaitTempMS, 1
    GOTO    DMS_START
    DECFSZ  SysWaitTempMS_H, 1
    GOTO    DMS_START
    RETURN
CLOCK_INIT
    BANKSEL OSCCON1         ; Go to bank 17
    MOVLW   B'01100000'     ; HFINTOSC and NDIV = 1
    MOVWF   OSCCON1
    CLRF    OSCCON3         ; Enable
    CLRF    OSCEN
    CLRF    OSCTUNE
    MOVLW   B'00000110'     ; 32MHz
    MOVWF   OSCFRQ
    RETURN
;-------------------------------------------------------------------
;                           MAIN ROUTINE
;-------------------------------------------------------------------
INICIO:
    CALL    CLOCK_INIT
    MOVLB   0x0000          ; Vai para o banco 0
    MOVLW   B'11111000'
    MOVWF   TRISB
R1:
    BANKSEL PORTB
    CLRF    PORTB               ; Turn off all leds
    MOVLW   B'00000001'         ; turn on led 1
    MOVWF   PORTB
    MOVLW   0X03                ; Define the delay in ms
    MOVWF   SysWaitTempMS_H     ; 1000ms 0x03E8 in HEX
    MOVLW   0XE8
    MOVWF   SysWaitTempMS
    CALL    DELAY_MS
    MOVLW   B'00000010'         ; turn on led 2
    MOVWF   PORTB
    MOVLW   0X03
    MOVWF   SysWaitTempMS_H
    MOVLW   0XE8
    MOVWF   SysWaitTempMS
    CALL    DELAY_MS
    MOVLW   B'00000100'         ; turn on led 3
    MOVWF   PORTB
    MOVLW   0X03
    MOVWF   SysWaitTempMS_H
    MOVLW   0XE8
    MOVWF   SysWaitTempMS
    CALL    DELAY_MS
    GOTO    R1
;-------------------------------------------------------------------
;                           END OF PROGRAM
;-------------------------------------------------------------------
    ENDTo assemble code and generate the hex just a simply command need to be used:
gpasm -p16f15376 blink.asmAfter te execution a file called blink.hex gonna be created.
The most interesting feature of this development board is that when connect to PC throught USB it is reconized as a mass storage device. And to program device it is only ncessary to copy the generated hex file to the mounted device. After copy the program imediatelly start to run.
Amazing post!
I am computer engineer and MSc in Informatics graduated in Federal University of Espírito Santo. I am a programming and electronics enthusiast and I made this site to share my ideas and experiments in programming, electronics and DIY. I hope you enjoy it.
Donate: monero
452LPJcRqkhiaMdwpJSrzY1CTQ6MQMDxxQkUwDHDjBCe3Pcb6p9dHnGBZYjhZX1gHGU86W8wunHJBVDx5bk2K2aoFYwSA36