Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    I will have to explore the Microchip bootloader a little more. I strayed away from it because I think it requires a .dll and I wanted a usb bootloader that would work with the standard microsoft drivers. The Diolan also uses encryption which is a very nice feature and the code size is slightly smaller.

    Plus I like a challenge...maybe if I can get this working it will give others another option for bootloaders and DT_INTS.

    So, on to what I have found today.

    From section 26.2.4 of the 18f4550 manual:

    Additionally, the Indexed Literal Offset Addressing
    mode may create issues with legacy applications
    written to the PIC18 assembler. This is because
    instructions in the legacy code may attempt to address
    registers in the Access Bank below 5Fh. Since these
    addresses are interpreted as literal offsets to FSR2
    when the instruction set extension is enabled, the
    application may read or write to the wrong data
    addresses.
    If I look at the .LST file for the blinky led program I see this:
    Code:
    00037 FLAGS                           EQU     RAM_START + 000h
      00000001            00038 GOP                             EQU     RAM_START + 001h
      00000002            00039 R4                              EQU     RAM_START + 002h
      00000004            00040 R5                              EQU     RAM_START + 004h
      00000006            00041 R6                              EQU     RAM_START + 006h
      00000008            00042 R7                              EQU     RAM_START + 008h
      0000000A            00043 R8                              EQU     RAM_START + 00Ah
      0000000C            00044 INT_Flags                       EQU     RAM_START + 00Ch
      0000000D            00045 RM1                             EQU     RAM_START + 00Dh
      0000000E            00046 RM2                             EQU     RAM_START + 00Eh
      0000000F            00047 RR1                             EQU     RAM_START + 00Fh
      00000010            00048 RR2                             EQU     RAM_START + 010h
      00000011            00049 RS1                             EQU     RAM_START + 011h
      00000012            00050 RS2                             EQU     RAM_START + 012h
      00000013            00051 wsave                           EQU     RAM_START + 013h
      00000014            00052 RetAddrH                        EQU     RAM_START + 014h
      00000017            00053 RetAddrL                        EQU     RAM_START + 017h
    Looking at the 2nd Capture.txt file I attached yesterday there are lots of MOVWF statements that reference the RAM areas above which are in RAM at locations under 0x5F.

    So a statement like MOVWF [0x14] is really MOVWF [FSR2+0x14] with the extended instruction enabled. This may then explain why the code jumps off into la la land and resets.

    I did not think to capture FSR2 last night during my debugging. I will do that tonight and see if it matches my theory. If it does then I think I will try to change the RAM_START to 0x060 so that the extended instruction engine will not use the FSR2 on the Ram addresses.

    Am I on the right path?

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by vamtbrider View Post
    I will have to explore the Microchip bootloader a little more. I strayed away from it because I think it requires a .dll and I wanted a usb bootloader that would work with the standard microsoft drivers.
    I think there are two usb bootloaders from microchip. One is a HID Bootloader. I don't think it requires any dll's. It is located inside the huge files that you download as a group. Once all the Microchip Application Libraries v2010-02-09 is installed, the .hex file is located here: C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader

    I believe you can just bring the hidbootloader exe to a different computer, and program over the usb. But I have not fully tried it yet. I have only got to the point where my chip was regognized by a computer that has never had any microchip software loaded on it.

    I need to try the executeable.

  3. #3
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    The Diolan bootloader works as a HID USB device and my end app will eventually be a HID devices as well. If I get time this weekend I will try the Microchip HID bootloader, as Bruce indicated that maybe the more solid solution.

    I am looking at changing the statement in MPASM P18F4550.inc from

    Code:
    ACCESS  EQU  0
    to

    Code:
    ACCESS EQU  1
    This will allow the RAM definitions to stay the same and get past the extended instruction issues with f<0x5F. The draw back will be a lot of BSR changes. We'll see how that works out.

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


    Did you find this post helpful? Yes | No

    Default

    The major issue you have with the Diolan loader is that it has Enhanced CPU mode
    enabled. I.E. XINST = ON.

    So code compiled with PBP simply is not compatible, and will not run on the PIC as
    expected unless you disable Enhanced CPU mode.

    Here's a simple example you can try. Make sure you set XINST = OFF, then run this;

    Code:
    MyVar VAR WORD
    LED VAR PORTD.0 
    
    Loops:
     FOR MyVar = 0 TO 100
       High LED        
       GOSUB BLINK  
    
       Low LED       
       GOSUB BLINK  
     NEXT MyVar
     
       Goto Loops 
    
    BLINK:
        PAUSE 200
        RETURN
        
        End
    Now run the exact same code, but set XINST = ON and give it a whirl.

    Once you flip that switch to enable Enhanced CPU mode, ALL your code needs to be using
    the extended instruction set. Try it with ACCESS EQU 1 as well. Still no go.
    Last edited by Bruce; - 26th March 2010 at 19:32.
    Regards,

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

  5. #5
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default It works

    What I found interesting is that PicBasicPro compiles this code correctly for XINT on. Using brackets and leaving out the access parameter for addresses under 0x5F.

    The blinky light code I originally posted now runs fine with the Diolan bootloader. The trick I found was to clear the FSR2L and FSR2H registers as the first instructions in my program. I also set Access equ 1.

    I think the main issue was that I never initialized the FSR2 register to zero in my code. The Diolan bootloader uses FSR2 and it could have any value in it when the app code runs.

    Since that is the register used for indexed addressing when XINST is on it must be set to zero to allow legacy code to run. Setting FSR2 to zero places the access bank and SFR's in memory just as if XINST was 0. I found this info in the data sheet. Had to read it about 10 times to make sure I was following it correctly.

    The next challenge I am working on is to get the USB interrupts working with DT_INTS and the Diolan Bootloader. The USB_DEV.ASM and USB_HID.ASM use FSR2/INDF2 for indirect addressing and as a general register in several routines. Those will need to be modified to use FSR0/1 and INDF0/1 instead.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Found label after column 1 etc errors

    OK. I am pulling my hair off. Cannot think what might be wrong here.

    I get errors like Found label after column 1 (INT_CREATE) or Illegal opcode (RBC_INT) or Address label duplicated in second pass (INT_RETURN).

    The PIC® is F819, with DT-INTS-14 and MPASM of course. Also commented the confg line in the *.inc file as it can be seen on the attached files.

    Ioannis
    Attached Files Attached Files
    Last edited by Ioannis; - 20th April 2010 at 15:14.

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


    Did you find this post helpful? Yes | No

    Default

    Did you forget these?

    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    Regards,

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

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    No Bruce. They are in pbp directory and the project too.

    It is not the first time I use these excellent routines.

    That is why I post here. I am almost driving myself in the la-la land with this!

    Ioannis

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Did you forget these?

    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    Compiles here as well, but I do get the same errors IF I leave the above lines out of the code. Are you sure the include lines are in your water?

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 21:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 07:32
  5. Replies: 1
    Last Post: - 1st November 2006, 04:11

Members who have read this thread : 4

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

Tags for this Thread

Posting Permissions

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