USBDemo with Bootloader


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    If you're using the Microchip USB boot-loader, you can drop some of your
    defines.

    DEFINE LOADER_USED 1 is only required if user code will start at 0. With the
    Microchip USB loader, it starts at 800h. You don't need this define.

    DEFINE RESET_ORG 800h ' This is required so user code is inserted at 800h (if
    using the Microchip USB Bootloader).

    DEFINE INTERRUPT_ORG 808h ' This one doesn't really do anything. If you're
    using assembler interrupts, then use the PBP DEFINE INTHAND or INTLHAND
    options for high/low interrupt vectors.

    The Microchip USB loader already has interrupt jump vectors setup in the
    loader firmware that will vector to 808h for high pri, and 818h for low pri
    interrupts.
    Code:
    #pragma code high_vector=0x000808
    void interrupt_at_high_vector(void)
    {
        _asm goto high_isr _endasm
    }
    #pragma code
    
    #pragma code low_vector=0x000818
    void interrupt_at_low_vector(void)
    {
        _asm goto low_isr _endasm
    }
    #pragma code
    In the USB loader firmware, at the hardware interrupt vectors, it has GOTO
    808h (for high pri) and GOTO 818h (for low pri). You just need to force PBP
    to stick your .asm int handlers (or a GOTO each one) in these locations.

    To do this, you tell PBP where your high & low interrupt service handlers will
    be using the INTHAND & INTLHAND defines below.

    DEFINE RESET_ORG 800h ' User code starts at 800h for USB Boot-Loader
    DEFINE INTHAND my_high_isr ' High priority int handler
    DEFINE INTLHAND my_low_isr ' Low priority int handler

    Now add your assembler interrupt handlers like this;

    Code:
    ASM
    my_high_isr
        ; do stuff here
        RETFIE FAST
    ENDASM
    
    ASM
    my_low_isr
        ; do stuff here
        RETFIE
    ENDASM
    PBP will place a GOTO my_high_isr at location 808h, and a GOTO my_low_isr
    at 818h.

    The rest of your code will start just after location 818h.

    You have re-mapped the reset vector to 800h with DEFINE RESET_ORG 800h
    so PBP knows where to stick these. It simply adds 08h or 18h to the reset
    address for the high/low priority interrupt locations.

    The USB firmware vectors to 808h for high pri, and 818h for low pri, and PBP
    has placed GOTO's in these locations vectoring to your re-mapped .asm
    interrupt handlers.

    If you're 100% sure you have all interrupts disabled, and you're never planning
    to use them, then you can drop the interrupt defines altogether.

    If you're not sure, or you do plan to use interrupts, and you're using the USB
    loader from Microchip, then it's a really good idea to setup these vectors.

    If you don't, then PBP will place 'user' code in locations the loader will vector
    to when an interrupt happens. Then you have no idea what's going to happen.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Jan 2007
    Posts
    70

    Default hmmmgrumble

    allrite.. well. i am reading these suggestions, and they are not entirely clear without the code in front of me. i wont have a chance to work on this tonite, but i should get time over the weekend...

    in the meantime, let me complain about microcode studio's lack of a config fuse editor! it really is a PIA, and it is causing lots of headaches.

    then also let me complain about the weird interaction between 18x series config flags, mpasm, and picbasic pro! why is it so abnormal feeling?

    also, let me repeat my initial question - has anyone gotten the USBDemo application from mister e to work with a usb bootloader?

    thanks!

Similar Threads

  1. PIC18F4680 bootloader
    By vinyl_theif in forum General
    Replies: 1
    Last Post: - 29th January 2009, 17:45
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. 18F2550 MCRL/RE3 problem with USB bootloader Microchip
    By Ronald123 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th September 2007, 10:48
  4. Using the Mecanique Bootloader without the DTR reset signal
    By picnaut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th September 2005, 03:39
  5. Bootloader Problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2005, 17:51

Members who have read this thread : 0

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