Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIC16F876A - Bootloader works only once [solved]
#1
Hello,

I've just started to try the latest (November 9th 2012) "ds30Loader free edition" but I can't manage to make it work more than once.
I've red some threads in the forum about the same problem, but none gave me a solution.

I'll try to be the more precise about what I've done:
* I've modified "firmware PIC12F PIC16F" as follow:
- in "settings.inc": LIST P=16F876A (it's the PIC I use)
- in "settings.inc": #define FOSC 20000000 (as I've a 20MHz quatz)
- in "settings.inc", configuration bits are now: __CONFIG _DEBUG_OFF &_HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _LVP_OFF
* in "ds30LoaderGui.exe":
- Device: PIC16F 876A
- Baud rate: 9600
- Port: USB Serial Port (the one of my FT232R connected to the PIC board)
- Write Flash: checked
- Advanced tab: nothing checked
- Timing tab: nothing changed
- Reset tab: RTS
- Activation tab: manual
- Security tab: nothing changed
- Terminal tab: nothing changed

The fist time I use the Bootloader, it is perfectly detected by the GUI and my program is uploaded (see debug log named "1st_prog.txt").
Then, there is no way to connect to bootloader again (see debug log named "after_1st_prog.txt"), but my program works fine (I think it's because my program is smaller than 0x0700, see disassembly "my program uploaded by the bootloader" below).

I've desassembled PIC memory with bootloader only:
Code:
; Program

    Org 0x0000
;   Reset-Vector
    BSF PCLATH,3
    BSF PCLATH,4
    GOTO LADR_0x0700    ; with the bank-select of two previous lines, gives: LADR_0x1F00
    ADDLW 0xFF  

;   Interrupt-Vector
    ADDLW 0xFF

...

LADR_0x1EFD
    NOP
    NOP
    NOP
LADR_0x1F00
    CALL LADR_0x078D     ; start of the bootloader firmware
...

My program only:
Code:
; Program

    Org 0x0000
;   Reset-Vector
    GOTO LADR_0x0005

    Org 0x0004
;   Interrupt-Vector
    RETFIE

LADR_0x0005
    CALL LADR_0x001E     ; start of my prog

And then my program uploaded by the bootloader:
Code:
; Program

    Org 0x0000
;   Reset-Vector
    MOVLW 0x98           ; line 1 (no bank selected -> bank 0)
    GOTO LADR_0x0700     ; line 2 (should go to 0x0700)
    ADDLW 0xFF           ; line 3
    ADDLW 0xFF

;   Interrupt-Vector
    RETFIE

LADR_0x0005
    CALL LADR_0x001E     ; start of my prog

...

LADR_0x1EFD
    MOVLW 0x80           ; line 4
    NOP                  ; line 5
    GOTO LADR_0x0005     ; line 6
LADR_0x1F00
    CALL LADR_0x078D     ; start of the bootloader firmware
...

It seems that in the bootloader firmware, the "bank select" are wrongly modified by the PC software and that lines 1 to 6 should be as follow:
Code:
;   Reset-Vector
    BSF PCLATH,3         ; line 1
    BSF PCLATH,4         ; line 2
    GOTO LADR_0x0700     ; line 3

...

LADR_0x1EFD
    BCF PCLATH,3         ; line 4
    BCF PCLATH,4         ; line 5
    GOTO LADR_0x0005     ; line 6

If someone has an idea, it will be great.

Best regards.


Attached Files
.txt   1st_prog.txt (Size: 2.7 KB / Downloads: 21)
.txt   after_1st_prog.txt (Size: 372 bytes / Downloads: 12)
Reply
#2
Hello,
Thank you for the detailed report. Your are absolutely correct.
The problem is that the 876A device is incorrectly interpreted as an enhanced mid-range device which supports the movlp instruction.

Please try this new version attached to this post.


Attached Files
.zip   ds30LoaderGui.zip (Size: 179.42 KB / Downloads: 31)
Reply
#3
(2012-12-05, 23:03:04)Mikael Gustavsson Wrote: Hello,
Thank you for the detailed report. Your are absolutely correct.
The problem is that the 876A device is incorrectly interpreted as an enhanced mid-range device which supports the movlp instruction.

Please try this new version attached to this post.

Hello,

Thanks a lot for your answer. With your new "ds30LoaderGui.exe" everything works fine !

Best regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)