You are on page 1of 5

PIC Microchip 1.

Hardware

2. Bootloader

Among the many features built into Microchips Enhanced FLASH Microcontroller devices is the capability of the program memory to self-program. This very useful feature has been deliberately included to give the user the ability to perform bootloading operations. Devices like the PIC16F877A or PIC18F452 are designed with a designated boot block, a small section of protectable program memory allocated specifically for bootload firmware. Cytron Enterprises have modified and applied bootloader firmware to PIC microcontroller which is ready to be used with simplest hardware interface. This user guide note demonstrates a very powerful bootloader usage for the PIC16F and PIC18F families of microcontrollers. The guide for 16F bootloader is slightly different from 18F bootloader. Thus, there will be 2 sections to setup and use bootloader. Cytron Enterprises have developed a new bootloader firmware for 16F877A. Since 16F families have a wide range of microcontroller with

plenty of memory size and configuration, this bootloader is created base on PIC16F877A. It has following features: a. Base on PIC16F877A, it should work for PIC listed below, however it have not been tested: i. PIC16F873A ii. PIC16F874A iii. PIC16F876A b. With bootloader firmware resized in PIC, user code must start from address 0x200. For assembly language, reset vector must start at address 0x200 while interrupt vector should start at 0x204. c. The configuration bits of new program code will be ignored as it cannot be accessed in bootloader mode. The configurations of bootloader firmware are listed. If configuration is need to be modified, please use programmer to do so. i. Oscillator = HS ii. Watchdog Timer = Off iii. Power Up Timer = On iv. Brown Out Detect = Off v. Low Voltage Program = Disabled vi. Flash Program Write = Write Protection Off vii. Data EE Read Protect = Off viii. Code Protect = Off
3. Schematic

4. LED Blinking

Sample Program for LED Blinking

;********************************************************************** ORG 0x000 ; processor reset vector goto main ; go to beginning of program main ; initialize of your PIC, setting the general I/O in TRIS BSF CLRF BSF BSF BSF BCF STATUS,5 TRISB TRISA,2 TRISA,3 TRISA,4 STATUS,5 ;SWITCH TO BANK 1 ;SET PORTB AS OUTPUT ;SET RA2 AS INPUT ;SET RA3 AS INPUT ;SET RA4 AS INPUT ;BANK 0 ;SET ALL 8 PIN IN PORTB TO HIGH(1)

MOVLW B'11111111' MOVWF PORTB ;the main program begin here START BTFSS CALL BTFSS CALL BTFSS CALL GOTO RED: BSF BSF BSF BCF RETURN GREEN: BSF BSF BSF BCF RETURN YELLOW: BSF BSF BSF BCF RETURN

PORTA,2 ;check signal at pushbutton1, RED ;button1 pressed, program execute the operation in subroutine RED PORTA,3 ;check signal at pushbutton2, GREEN ;button2 pressed, program execute the operation in subroutine GREEN PORTA,4 ;check signal at pushbutton3, YELLOW ;button3 pressed, program execute the operation in subroutineYELLOW START ;no any button being pressed, program keep looping to check the pushbuttons' PORTB,4 PORTB,5 PORTB,6 PORTB,6 ;ON YELLOW LED ;ON GREEN LED ;ON RED LED ;OFF RED LED

PORTB,4 PORTB,5 PORTB,6 PORTB,5

;ON YELLOW LED ;ON GREEN LED ;ON RED LED ;OFF GREEN LED

PORTB,4 PORTB,5 PORTB,6 PORTB,4

;ON YELLOW LED ;ON GREEN LED ;ON RED LED ;OFF YELLOW LED

;*******************************DELAY SUBROUTINE***************************** DELAY MOVLW D'200' MOVWF D3 MOVLW D'3' MOVWF D2 MOVLW D'1' MOVWF D1 DECFSZ ;PAUSE FOR ABOUT 500mS

D1

GOTO $-1 DECFSZ GOTO $-5 DECFSZ GOTO $-9 RETURN END ; directive 'end of program'

D2 D3

You might also like