DEFINE RESET_ORG and DT Instant Interrupt


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    82

    Default DEFINE RESET_ORG and DT Instant Interrupt

    Hi all,
    anybody can understand why the below code works only commenting the first line ?
    If I use DEFINE RESET_ORG the program hangs and does nothing.

    Code:
    '    DEFINE RESET_ORG 3000h
    
        include "declare.inc"
        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   TMR1_INT,  _Timer1_250mS_INT,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
        @    INT_ENABLE  TMR1_INT         ; enable Timer1 interrupts
    
        OSCCON        =%100000            ; Primary oscillator, internal 8MHz
        OSCCON2.0    =1
        OSCTUNE.7    =1
        T1CON        =%110111            ; Timer1, 1:8 prescaler, 262mS Interrupt
    
        INTCON.7=1                        ; global int
        INTCON.6=1                        ; peripheral int
    
    MyLoop:
        Hserout2["Hello ... ",#x,13,10]
        x=x+1
        pause 500
        goto MyLoop
        
    Timer1_250mS_INT:
        toggle led 
        @ INT_RETURN

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: DEFINE RESET_ORG and DT Instant Interrupt

    Because, you need to reroute reset interrupt vectors.
    PIC always jump to 04 and 08 on hi/lo int.
    And you don't have anything there.
    Generally that is bad idea, because you hijack interrupts from main code.
    And that reroute you cant do in PBP, nor ASM at compile time. So you need to do it manually. Then you can reroute int vectors in main program, to some other location.
    And all that is just bad.

    What exactly you are trying to do. I know you are building bootloader, I have posted few on this forum.
    It should be very easy, straight forward code... Not sure why you need interrupts.

  3. #3
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: DEFINE RESET_ORG and DT Instant Interrupt

    Hi Pedja,
    this is a sample program that runs ok without the DEFINE RESET_ORG.
    What I'm trying to do is move it from org 0 to create place for my bootloader.
    My real program needs interrupt.

    I think I have read that interrupt vector are moved automatically when you use DEFINE RESET_ORG, you say not ?
    Can you drive me how to remap int vector ?

  4. #4
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: DEFINE RESET_ORG and DT Instant Interrupt

    I describe my idea.

    1) Write a bootloader program at ORG 0 that get an HEX file and write memory starting at 3000h
    2) export code, manipulate to obtain something like below and put it in a file "bootloader.inc"

    Code:
    ASM
    	dw 0x0EF5B, 0x0F002, 0x0FFFF, 0x0FFFF, 0x0EFAA, 0x0F003, 0x0FFFF, 0x0FFFF, 0x0FFFF, 0x0FFFF, 0x0FFFF, 0x0FFFF
    	dw 0x0E00B, 0x00606, 0x0C004, 0x0FFE9, 0x0C005, 0x0FFEA, 0x050EE, 0x0CFE9, 0x0F004, 0x0CFEA, 0x0F005, 
    	dw 0x00004, 0x0A89E, 0x0D7FD, 0x06EAD, 0x080D8, 0x0EF58, 0x0F002, 0x050E9, 0x0010F, 0x00004, 0x0A8A4, 
    ENDASM
    3) Take my main program and add DEFINE RESET_ORG 3000h
    4) at the end of the program add

    Code:
    @ ORG 0h
    BootLoader:
    	include "BootLoader.inc"
    Then I can call the bootloader with a GOTO @0.

    Of course it doesn't work .....

  5. #5
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: DEFINE RESET_ORG and DT Instant Interrupt

    If in the main program (with DEFINE RESET_ORG 3000h) I add this

    Code:
    @ ORG 0
    	@ GOTO 3000h
    @ ORG 8
    	@ GOTO 3008h
    @ ORG 4
    	@ GOTO 3004h
    It works....
    But when I want to jump to bootloader I need the vector remapped to 4 and 8....

    Maybe I can use WRITECODE to overwrite the INT vector before jumping to bootloader and then again WRITECODE before exit from bootloader ?

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: DEFINE RESET_ORG and DT Instant Interrupt

    Now I got it.
    I have done bootloaders on top of main program. At address 64000. So in main program i call bootloader with @ GOTO 64000. No need to remap anything.


    When you use reset org 3000h, PBP expect int vectors on 3008h, but CPU will jump at 08h.

    So in your bootloader you need to have
    Code:
    @ ORG 8
    	@ GOTO 3008h
    @ ORG 4
    	@ GOTO 3004h
    Then CPU will jump to 08h, then jump to 3008h, then jump to ISR. Lot of jumping...
    Also, when you power PIC it will enter to bootloader first, so you need exit from bootloader
    eg
    Code:
     @ GOTO 03000h
    But this
    Code:
    @ ORG 8
    	@ GOTO 3008h
    @ ORG 4
    	@ GOTO 3004h
    will generate warning in ASM, overwriting prev address, or something like that. Then it depends, what was last, so it may assemble correctly, maybe not.
    EDIT:
    You could try something like this in bootloader:
    Code:
    Reset org 10h
    @ ORG 0
    	@ GOTO 10h
    @ ORG 8
    	@ GOTO 3008h
    @ ORG 4
    	@ GOTO 3004h
    Last edited by pedja089; - 3rd February 2021 at 13:19.

Similar Threads

  1. DEFINE RESET_ORG and DEC modifier issue
    By Marcick in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 5th February 2021, 07:21
  2. DT Instant Interrupt and Bootloader
    By mikebar in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd September 2014, 08:26
  3. Define Interrupt Label Problem
    By Junkman55 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 14th June 2011, 17:41
  4. Instant Interrupt and USART
    By sirvo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd July 2008, 03:08
  5. DT Instant Interrupt counting
    By jderson in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 9th March 2008, 22:47

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