bootloader confusion
take this pgm
Code:
'****************************************************************
'* Name :blinky.pbp *
'* Author : richard *
'* Notice : *
'* : *
'* Date : *
'* Version : 16f1825 @3.3 volts *
'* Notes : *
'* : *
'*
'****************************************************************
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
DEFINE LOADER_USED 1
DEFINE OSC 32
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 207 ' 38400 Baud @ 32MHz,
SPBRGH = 0
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
led var latc.0
TRISA=%111111
TRISC=%111110
OSCCON=$F0
ANSELA=0
ANSELC=0
while !OSCSTAT.6
wend
hserout [ "Ready",9,"%",bin6 trisc,13,10]
mainloop:
led=!led
pause 1000
goto mainloop
when loaded with pk2
printout
Ready %111110
when loaded with bootloader
Ready %111110
ie all portc is input except bit 0, yet hserout works tx=portc.4
data sheet says
Setting the TXEN bit of the TXSTA register enables the
transmitter circuitry of the EUSART. Clearing the SYNC
bit of the TXSTA register configures the EUSART for
asynchronous operation. Setting the SPEN bit of the
RCSTA register enables the EUSART and automatically
configures the TX/CK I/O pin as an output. If the TX/CK
pin is shared with an analog peripheral, the analog I/O
function must be disabled by clearing the corresponding
ANSEL bit.
all is good
yet for the bootloader
Code:
; optional path information - default output folder is
; user documents -> umcbuild...
[PATH]
Output=C:\MYBOOTLOADER
[TEMPLATE]
;PIC18=..\src\18F\umc_loader.asm
PIC16=..\src\16F\umc_loader.asm
; device name and OSC...
[MCU]
Device=16F1825
OSC=32000000
[USART]
BAUDRATE = 19200 ; initial startup baudrate (default is 19200)
BRGH16 = 1 ; 16 bit SPBRG support (default is OFF)
; device configuration settings...
[CONFIG] ;----- CONFIG1 Options --------------------------------------------------
__config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_ON & _LVP_OFF
; place startup code in here...
[USERCODE]
movlb 3
BCF ANSELC,5
BCF ANSELC,4
movlb 1
BCF TRISC,4 without this bootloader fails
BSF TRISC,5
movlw 0x70 ; 32 MHz
movwf OSCCON
btfss OSCSTAT,6
goto $-1
I just don't follow it
Bookmarks