2013-06-24, 15:11:59
I will appreciate help with this.
Spent days and can not get the bootloader to work at all. With a C program, comms Tx and Rx works and the MCP2200 Usb to serial converter works 100%.
I have tried just every option with clock speeds, configurations, etc. I also tried it with the latest bootload version.
The Osc is running 64000000 with the PLL but the code gives an error and I therefore switch off the PLL to run 16000000 hz.
Here is my user setup, changed to enable the MCP2200 and a led, tried with and without the OSCCON setup:
USER_CODE.INC:
SETTINGS.INC:
Attached is the code listing...
Spent days and can not get the bootloader to work at all. With a C program, comms Tx and Rx works and the MCP2200 Usb to serial converter works 100%.
I have tried just every option with clock speeds, configurations, etc. I also tried it with the latest bootload version.
The Osc is running 64000000 with the PLL but the code gives an error and I therefore switch off the PLL to run 16000000 hz.
Here is my user setup, changed to enable the MCP2200 and a led, tried with and without the OSCCON setup:
USER_CODE.INC:
Code:
; UserInit()
; Description: this is executed immediately on start-up before the boot loader code
;------------------------------------------------------------------------------
UserInit macro
; enable MCP2200
movlw b'11110110' ; setup clock to 16M clock speed
movwf OSCCON
bcf 0x0F93,6 ; tris B6 out
bcf 0x0F81,6 ; pin B6 // ce low
bsf 0x0F81,6 ; pin B6 // ce high
bcf 0x0F93,4 ; tris B4 out
bsf 0x0F81,4 ; pin B4 blue led
;
; Make uart pins digital
ifdef ADCON1
; error Do you need to configura uart pins to be digital? If not, remove this line
endif
;movlw b'01100000' ;xxx disable
;movwf ADCON1 ;xxx analog on tx/rx
; UART/CAN pps config
ifdef HAS_PPS
ifdef USE_UART2
error You need to configure PPS ;xxx remove this line when PPS is configured
; This template maps U2Rx to RP4
bcf RPINR16, RX2DT2R0 ;xxx
bcf RPINR16, RX2DT2R1 ;xxx
bsf RPINR16, RX2DT2R2 ;xxx
bcf RPINR16, RX2DT2R3 ;xxx
bcf RPINR16, RX2DT2R4 ;xxx
; This template maps RP3 to U2Tx
bsf RPOR3, RP3R0 ;xxx
bcf RPOR3, RP3R1 ;xxx
bsf RPOR3, RP3R2 ;xxx
bcf RPOR3, RP3R3 ;xxx
bcf RPOR3, RP3R4 ;xxx
endif
endif
endm
;------------------------------------------------------------------------------
; UserExit()
; Description: this is executed right before the user application is loadaed
;------------------------------------------------------------------------------
UserExit macro
endm
SETTINGS.INC:
Code:
;------------------------------------------------------------------------------
; Device
;------------------------------------------------------------------------------
processor 18F14K22 ;xxx
;------------------------------------------------------------------------------
; Includes
;------------------------------------------------------------------------------
#include "devices.inc"
;------------------------------------------------------------------------------
; User preferences
;------------------------------------------------------------------------------
radix DEC
#define OSCF 16000000 ;xxx oscillator frequency (including pll)
#define BLINIT 2000 ;xxx hello receive timeout [ms]
#define HELLOTRIES 2 ;xxx number of non hello characters received before branching to the user application
#define BLTIME 2000 ;xxx data receive timeout [ms]
;------------------------------------------------------------------------------
; UART settings
;------------------------------------------------------------------------------
#define USE_UART1 1 ;xxx uncomment to use uart1
;#define USE_UART2 1 ;xxx uncomment to use uart2
#define BAUDRATE 38400 ;xxx baudrate
;#define USE_ABAUD 1 ;xxx uncomment to use auto baud rate detection, READ ERRATA FIRST
;#define USE_BRG16 1 ;xxx uncomment to use 16-bit brg
;#define USE_TXENABLE 1 ;xxx uncomment to use a tx enable pin
ifdef USE_TXENABLE
#define TXE_DELAY 10 ;xxx time in us to wait before transmitting after pulling the tx enable pin high
#define TRISR_TXE TRISD ;xxx tris register containing tx enable
#define LATR_TXE LATD ;xxx port register containing tx enable
#define TRISB_TXE TRISD0 ;xxx tris bit for tx enable
#define LATB_TXE RD0 ;xxx port bit for tx enable
endif
;------------------------------------------------------------------------------
; Advanced settings
;------------------------------------------------------------------------------
;#define KICK_WD 1 ;xxx uncomment to kick the wd in the rx loop, only enable if the watchdog is enabled
#define PROT_GOTO 1 ;xxx protect goto at 0x00
#define PROT_BL 1 ;xxx protect bootloader
#define WRITE_VER 1 ;do flash write verification
#define EWRITE_VER 1 ;do eeprom write verification
ifdef IS_PIC18F
#define BLPLP 9 ;bootloader placement, pages from end
#define BLSIZEP 9 ;bootloader size [pages], used by bootloader protection
endif
ifdef IS_PIC18FJ
#define BLPLP 2 ;bootloader placement, pages from end
#define BLSIZEP 1 ;bootloader size [pages], used by bootloader protection
endif
Attached is the code listing...