Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIC18F45K80 issues [solved]
#1
Really impressed with the bootloader. Downloaded it, modified the settings.inc file, assembled and downloaded to part and worked first time. However, I tried successive attempts to bootload and I get several failures in between successful attempts. The download starts and then the data stops getting sent/received. Then the GUI notes an error in # of data bytes. Just wondering if anyone else has seen this and what was the resolution.

Thanks in advance for any help.



Here is the settings.inc file contents. This is the only file that I changed. The PIC18 hex file that I am bootloading was compiled with the Hitech compiler. Both bootloader and Hitech code were set for release, not debug.


;------------------------------------------------------------------------------
; Device
;------------------------------------------------------------------------------
processor 18F45K80 ;xxx
;------------------------------------------------------------------------------
; Includes
;------------------------------------------------------------------------------
#include "devices.inc"
;------------------------------------------------------------------------------
; User preferences
;------------------------------------------------------------------------------
radix DEC

#define OSCF 16000000 ;xxx oscillator frequency
#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 TRISR_TXE TRISD ;xxx tris register containing tx enable
#define LATR_TXE LATD ;xxx port register containing tx enable
#define TRISB_TXE TRISD5 ;xxx tris bit for tx enable
#define LATB_TXE RD5 ;xxx port bit for tx enable
#endif
;------------------------------------------------------------------------------
; Advanced settings
;------------------------------------------------------------------------------
#define PROT_GOTO 1 ;xxx protect goto at 0x00
#define PROT_BL 1 ;xxx protect bootloader

ifdef IS_PIC18F
#define BLPLP 8 ;bootloader placement, pages from end
#define BLSIZEP 8 ;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


;------------------------------------------------------------------------------
; Configuration bits, these macros can be found at the end of the inc-files located in
; C:\Program Files\Microchip\MPASM Suite\
;
; These can also be set in MPLAB IDE instead, they are found in Configure->Configuration bits...
;------------------------------------------------------------------------------

; xxx

CONFIG RETEN = OFF ;Ultra low-power regulator is Disabled (Controlled by REGSLP bit)
CONFIG INTOSCSEL = LOW ;LF-INTOSC in Low-power mode during Sleep
CONFIG SOSCSEL = DIG ;Digital (SCLKI) mode
CONFIG XINST = OFF ;Disabled
CONFIG FOSC = HS1 ;HS oscillator (Medium power, 4 MHz - 16 MHz)
CONFIG PLLCFG = OFF ;Disabled
CONFIG FCMEN = OFF ;Disabled
CONFIG IESO = OFF ;Disabled
CONFIG PWRTEN = ON ;Enabled
CONFIG BOREN = OFF ;Disabled in hardware, SBOREN disabled
CONFIG BORV = 0 ;3.0V
CONFIG BORPWR = MEDIUM ;BORMV set to medium power level
CONFIG WDTEN = OFF ;WDT disabled in hardware; SWDTEN bit disabled
CONFIG WDTPS = 1048576 ;1:1048576
CONFIG MCLRE = ON ;MCLR Enabled, RG5 Disabled
CONFIG STVREN = ON ;Enabled
CONFIG BBSIZ = BB1K ;1K word Boot Block size
CONFIG CP0 = OFF ;Disabled
CONFIG CP1 = OFF ;Disabled
CONFIG CP2 = OFF ;Disabled
CONFIG CP3 = OFF ;Disabled
CONFIG CPB = OFF ;Disabled
CONFIG CPD = OFF ;Disabled
CONFIG WRT0 = OFF ;Disabled
CONFIG WRT1 = OFF ;Disabled
CONFIG WRT2 = OFF ;Disabled
CONFIG WRT3 = OFF ;Disabled
CONFIG WRTC = OFF ;Disabled
CONFIG WRTB = OFF ;Disabled
CONFIG WRTD = OFF ;Disabled
CONFIG EBTR0 = OFF ;Disabled
CONFIG EBTR1 = OFF ;Disabled
CONFIG EBTR2 = OFF ;Disabled
CONFIG EBTR3 = OFF ;Disabled
CONFIG EBTRB = OFF ;Disabled

;------------------------------------------------------------------------------
; End of file
;------------------------------------------------------------------------------
Reply
#2
Hi,
Thanks for posting. You have enabled a tx enable pin. That should only be done when using RS485.
Have you tried different baud rates? What is the output in the gui when it fails?
Reply
#3
Hi Mikael,
I am using RS485 transceiver. It appears that this functionality is working fine.

The error I get is:
===========================
Found PIC18F45K80 fw ver 3.0.0
Waiting for bootloader to be ready ... ok
Parsing hexfile ...
File timestamp: 1/5/2012 9:10:04PM
Validating hex file ... ok
Hex file successfully parsed
Writing flash ... response timed out
Tx 4.6kB / Rx 128 bytes / 14s
Write failed
===========================

The only thing that changes from one failed attempt to the other is the Tx bytes, Rx bytes and time. Everything else is the same.

I have tried 9600, 14400, 19200, 28800, 38400 and 57600. The failures are fewer today. I am getting more successful attempts than failures. 38400 and 57600 show more failures than the others. It seems that 9600 and 28800 did not show any errors in 10+ attempts while others showed one or more failures in 10 attempts.
Reply
#4
You could try to increase the delays surrounding the tx enable pin as described in the fourth post in this thread:
http://mrmackey.no-ip.org/elektronik/ds3...hp?tid=461
Try different number of NOPs.
Reply
#5
Thanks Mikael,
I am off to CES tomorrow for the week but will try next weekend when I return. Given that I am running at 16MHz, this sounds very likely to be the issue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)