how to remap interrupt vector - pic18f4550


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Jul 2011
    Posts
    21

    Default how to remap interrupt vector - pic18f4550

    hi

    can any one tell me how to remap interrupt vector in pbp or assembly? i have written a bootloader which loads new firmware with help of external eeprom. when interrupt occurs in the new firmware it then jumps to bootloader interrupt vector and gets hang/reset. to solve this problem i need to remap interrupt vector in my bootloader
    please help me

    thank you

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    It depends what you mean by "remap".
    If you are writing a bootloader, it is likely that you will have to deal with a variety of devices, so you will have only one interrupt level. When a PIC gets an interrupt, it jumps to location 0x08. Put a jump to whatever you want in that location.
    Charles Linquist

  3. #3
    Join Date
    Jul 2011
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    Quote Originally Posted by Charles Linquis View Post
    It depends what you mean by "remap".
    If you are writing a bootloader, it is likely that you will have to deal with a variety of devices, so you will have only one interrupt level. When a PIC gets an interrupt, it jumps to location 0x08. Put a jump to whatever you want in that location.
    thanks for your reply.
    but how to put jump instruction at 0x0008? i tried using this asm code but i got error "overwriting previous address content"
    Code:
    asm
    org 0x0008
    goto 0x2008
    endasm
    also if i am putting jump at 0x0008 then if in bootloader interrupts (usb rx interrupts) occur then it will also jump to 0x0008 and then to 0x2008?
    thanks

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    It would appear that you already have an INT assigned. As a result, there is something in that location already and you are over-writing it.

    ALL high priority interrupts go to 0x08. You are responsible for deciding what generated the interrupt by reading PIR(x.x and others) and doing the correct things.
    Charles Linquist

  5. #5
    Join Date
    Jul 2011
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    Hi Charles,
    i created this simple program and tried to run but it didn't worked. it should blink led and remap high priority interrupt vector
    adcon1 = 15
    DEFINE OSC 48

    asm
    org 0x0008
    goto 0x2008
    endasm

    i var byte
    j var byte

    main:
    high porta.0
    for i = 0 to 254
    for j = 0 to 254
    high porta.0
    next j
    next i
    for i = 0 to 254
    for j = 0 to 254
    low porta.0
    next j
    next i
    goto main
    but if i comment out the goto 0x2008 line it starts to blink led. since i am not using any interrupt then why its not blinking led?
    can you please help me

    thank you

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    I hope there is more to your program that you show. The PIC jumps to the interrupt vector location (0x08) when some peripheral (timer, serial port, etc) generates an interrupt, at which time the program counter gets reset to 0x08.

    Just use Darrel's Instant Interrupts.
    Charles Linquist

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: how to remap interrupt vector - pic18f4550

    I should add that the program counter jumps to 0x08 whenever both the a particular interrupt ENABLE and interrupt FLAG are both set. The program counter won't
    jump around location 0x08 unless you tell it to. So at location 0x00, you need a jump to a location AFTER 0x08

    I currently use a technique where I get data in an RS-232 input buffer at 230Kbaud, and the data must not be blocked (must be able to receive at all times), and the data must be processed
    and a response given very quickly. Receiving the data in an ISR was no trouble, but processing and responding inside that ISR would block the next bytes, if they came immediately
    after the first.

    Processing and sending the data in the main loop (which was long), didn't work either because that would sometimes delay the response by up to .5 sec.

    So, I set up the RX_INT as high priority, and just before the INT_RETURN, I set the TMR3 interrupt flag. But I don't have Timer3 running! Timer 3 interrupt is turned on, but is low priority.
    The Timer 3 ISR jumps to the "process and send" routine".
    If a packet comes in (I'm using an Ethernet to RS-232 converter, and I don't have flow control connected), it always gets captured. As soon as the packet is received, it triggers
    the "process and send" routine. If another packet comes in immediately, the recieve ISR is entered again, since it is at a higher priority. Pointers insure that new data doesn't over-write old data.
    Now the latency is 4-7 mSec, since it doesn't have to wait for the main loop to complete.
    Charles Linquist

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    Along the same lines of recieving data,
    I frame the data with a start(to take) and end(to trigger) char, fast enough to be handled in the interrupt routine, then flag basic looping at 10X/sec.

    IE......... [ abcdxyz...COMMAND.....1234]

    "[" to start taking chars to array,
    "]" to stop taking and flag to basic to parse for command ete etc.

    the "[" always sets the array back to start.

    Don
    Amgen

  9. #9
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    But I don't have that luxury. I'm getting SNMP packets (80-230 bytes). The host sends me a request, and has about a 20mSec timeout. I have to do an enormous amount of processing to decode the packets, grab the appropriate data, rebuild the response packet, and send. I previously did everything (receive, process, send) in one long ISR. That worked great. I was getting queries every 410mSec. The problem is - the customer added a second host that was sending me queries every 1 second. Most of the time, all was OK. But of course, there were times when the two requests hit me at virtually the same time. Since I was processing and sending in the 'receive' ISR, I missed the second request. I should mention that I don't have any flow control out of my network port. The hardware is already in the field and the handshake lines are not connected.
    So I made the ISR a 'receive only' segment and made my buffer twice as long (so it could handle two incoming packets), and modified my routines so that they worked with an offset. Offset '0' is the first byte of the first packet and offset $100 is the first byte of the second packet.
    When a packet came in, I set flags (packet offset 0 recieved and packet offset $100 received) and tested those flags in my main loop. Unfortunately, my main loop takes up to .5 second to execute. The host would time out before I sent my response.
    So I set up Timer3 Int as a low-priority int, but didn't turn on the timer. I set PIR2.1 just before I exit the (high priority) receive ISR. As soon as it exits, it goes into my 'fake' TMR3 int and processes and sends the packet. If another packet comes in right after the first, the high priority receive interrupt stops the 'process and send' routine and grabs the packet. It then goes right back to processing and sending - both packets if it needs to. I'm running the net-port to PIC interface at 230K baud.
    It all works!
    Last edited by Charles Linquis; - 10th November 2011 at 01:02.
    Charles Linquist

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    OK, I think I follow your sequence. Sounds like your using Basic serout or HWserout ??
    I use TXint to send from either ram(array) or flash(1 of several tables at the end of flash mem).
    I will put together the easy change to PB18....lib for arrayread and send you. You (and me too) can be confident since Darrel checked it out.
    Don

  11. #11
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    I'm using HWserout, but I don't think I could do much better using TXint. It isn't the sending time that is the problem, it is the large amount of processing I have to do with the packets.
    SNMP requires that I do lexicographical sorts (1.2.1.3.1.1.1.4.2.1 is before 1.2.1.3.1.1.1.4.2.1.1 and 1.2.1.3.1.1.1.4.2.1 is after 1.2.1.3.1.1.1.3.9.9.9.9.9.9.9)
    Even if you get sent a string that does not match one that you have (internally) in your list, you have to pick the first item in your list that (lexicographically) comes after the received string,
    then grab the appropriate data, perform encryption on certain bytes (3 different types, depending on the data), re-assemble the variable-length packets, calculate the LRCs, and send.
    And some of the data is a (calculated) number 40 bits long.
    Charles Linquist

  12. #12


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    alot to ask of a PIC !

  13. #13
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Recieving data

    It is doing a lot of data collection at the same time. That is why I'm running my '8723 at 40MHz and it is full of code.
    Charles Linquist

Members who have read this thread : 2

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