18F4550 boot loader and corruption


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2008
    Posts
    13

    Default 18F4550 boot loader and corruption

    All,
    I have an odd problem and I thought I’d see if anyone had $.02 worth of info that might help me. I have a USB program running on 18F4550s. I have about 40 of these devices in service, 2 have Microchip HID v2.3 bootloader, 38 do not.

    The 2 with bootloaders keep corrupting the program code. After a week or 2 of running 4 to 6 hours a day the 2 units with bootloaders just stop working, or parts of the code stop working for no reason. I pull the chips off, read the code, and it’s been modified since installation. It’s never the same corruption, and it never happens on my none bootloader version. I’m not even booting into bootloader mode, it’s just there in case I want to upgrade.

    I’ve gone as far as to switch out my bootloader test units with 2 from the working 38. The problem follows the code, not the board/chip.

    The only thing I can think of somehow my program is messing up in the stack and getting pointed back to the first 1000h of code, jumping to a piece of ‘write’ code and accidently over writing some of my PBP code. I have no idea if this is actually what is happening, but it’s the only thing I can come up with.

    I’ve read where nested gosubs can be an issue. I have 7 gosub routines in my program, but none of them are nested, each one is called from the main loop only.

    I’m also using DT interrupts to do my USB service and to monitor if TMR0 rolls over, like this:

    <code>
    ‘DT USB_INT setup
    INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler USB_INT, _DoUSBService, PBP, yes
    INT_Handler TMR0_INT, _CountPulse1, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM
    @ INT_ENABLE TMR0_INT ; enable TMR0 interrupt
    @ INT_ENABLE USB_INT

    MainLoop:
    <--- my code---- >
    Goto MainLoop

    ‘routine for the USB interrupt, DT Code I found on here
    DoUSBService:
    IF IDLEIF THEN Plugged = 0
    IF SOFIF THEN Plugged = 1
    usbservice
    @ INT_RETURN

    CountPulse1:
    Pulser1[1] = Pulser1[1] + 1
    @ INT_RETURN
    </code>

    The only difference in my PBP code between the 2 versions is I have the following lines on my boot loader compiled code:
    DEFINE LOADER_USED 1
    DEFINE RESET_ORG 1000h

    Besides that my code is pretty plane jane, nothing fancy, nothing crazy…. due to the nature of the project I can’t post all of my code.

    I’ve thought about modifying the C bootloader code and replacing the WriteFlashBlock, WriteConfigBits, WriteEEprom routines with the C version of this:
    Write 10,11
    Write 11,22
    @ Reset

    In my program read 10 and 11 on each boot to see if they are ever set 11 and 22. If I find 11, 22 I could display an error to my LCD so I could confirm this is what is happening. But this is all speculation.

    Any ideas, or other ideas? I’m about to jettison the HID boot loader all together, but I’d love to keep it if possible..

    TIA
    Brad
    Last edited by bradb; - 20th June 2009 at 08:24. Reason: clean up wording...

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts