WRITECODE, ERASECODE, and interrupts


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263

    Question WRITECODE, ERASECODE, and interrupts

    For WRITECODE, my PBP manual (2.60) states (p. 176):

    If interrupts are used in a program, they must be turned off (masked, not DISABLED) before executing a WRITECODE, and turned back on (if desired) after the WRITECODE is complete.

    It recommends using

    DEFINE WRITE_INT 1

    1. Is this likewise necessary with DT interrupts?

    2. Is this also the case with ERASECODE? (The manual does not say.)

    3. Is this a toggle?

    And . . .

    4. The manual gives the syntax:

    ERASECODE Block

    If a block is 32 words (16F88), may I assume that this can be done in a loop, incrementing the STEP by 32 ($20) each time?
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default

    1. DT interrupts are just ordinary interrupts (except that Darrel has made them easy to use). So normally, I would say YES. But in searching through the PBPPIC14 LIB, I see that WRITE_INT is only used for WRITECODE. It is not used for READCODE or ERASECODE.

    Flash READS and ERASES probably aren't so time critical, but It never hurts to turn off interrupts when you don't need them, especially if your ISRs take a long time to run.

    2. See above.

    3. WRITE_INT is not a toggle. It turns off global int at the beginning of the WRITE and turns them on again immediately after the write.

    4. I believe you are correct. I have performed this operation before - but that was several years ago.
    Charles Linquist

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Thanks, Charles.

    The PBP manual says of DEFINE WRITE_INT 1

    Disable/enable global interrupts in Write, which is why it sounded like a toggle to me.

    Looking at the 16F88 manual at 3.6.1, "FLASH PROGRAM MEMORY ERASE SEQUENCE", Step 3 is "Disable interrupts". Oddly, there is no complementary step to re-enable them. However, the code example 3-4 shows disabling interrupts with

    BCF INTCON,GIE

    and then enabling them again with

    BSF INTCON, GIE

    Equally oddly, the example at 3-5 for writing to flash program memory has the BSF at the end but not the BCF anywhere prior.

    So . . .

    It looks like interrupts do need to be disabled/re-enabled with ERASECODE, too.

    Any reason why I can't just use an @ ahead of the above statements instead of the DEFINE? Would it save any time/space?
    Last edited by RussMartin; - 5th March 2010 at 19:56.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default

    You can just put an @ in front - BUT

    Disabling interrupts is slightly trickier than just one statement.
    Read Microchip AN576
    Charles Linquist

Similar Threads

  1. Bootloader and Instant Interrupts Atn:_DT_
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th May 2007, 01:59

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