Write EEPROM with Interrupts


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2021
    Location
    Illinois, USA
    Posts
    10

    Question Write EEPROM with Interrupts

    I am getting closer to the testing stage of my project but have one question. In the PBP manual it says that if interrupts are used the following define should be used.

    DEFINE WRITE_INT 1

    further in the code I have a sequence of writes, four in a row like below,

    write Degrees_up, word vdegrees_up
    write Degrees_10, word vdegrees_10
    write Degrees_20, word vdegrees_20
    write Degrees_30, word vdegrees_30
    .
    .
    rest of code

    If I am reading the manual correctly, the define statement will mask and unmask the interrupts while the write is occurring. Is this correct?

    Thanks for any clarification you can provide.

    Zapman

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Write EEPROM with Interrupts

    First, you don't mention which PIC you're using. Newer ones have a NVM Interrupt that can be used to set an interrupt when done writing to the EEPROM. Older ones need the GIE disabled when writing to the EEPROM. This might be a start.

  3. #3
    Join Date
    Dec 2021
    Location
    Illinois, USA
    Posts
    10


    Did you find this post helpful? Yes | No

    Red face Re: Write EEPROM with Interrupts

    Sorry I didn't mention the chip. It is a PIC18F45K80. I was asking because the PBP manual talks about needing to mask the interrupts during EEPROM writes. I am using DT's interrupt handling software and have modified it for the K80. My real question is do I use the Define statement to handle masking the interrupts during EEPROM writes?

    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: Write EEPROM with Interrupts

    If in your design, an interrupt can occur during EEPROM write, then use GIE bit to disable temporary all interrupts. After WRITE enable GIE again. Thats all.

    Ioannis

  5. #5
    Join Date
    Aug 2011
    Posts
    439


    Did you find this post helpful? Yes | No

    Default Re: Write EEPROM with Interrupts

    If you use 'DEFINE WRITE_INT 1' then the library code will disable interrupts around the unlock and setting EECON1.WR to initiate the write operation, but unlike the sequence shown in most datasheets it will reenable them before the write operation is completed.

  6. #6
    Join Date
    Feb 2023
    Posts
    7


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Write EEPROM with Interrupts

    That"s right, DEFINE WRITE_INT 1 is all that you need. I have used it for about 7 years with out any problems. I used to use Ioannis way at first and it worked as well.

  7. #7
    Join Date
    Dec 2021
    Location
    Illinois, USA
    Posts
    10


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Thumbs up Re: Write EEPROM with Interrupts

    Quote Originally Posted by DaveP View Post
    That"s right, DEFINE WRITE_INT 1 is all that you need. I have used it for about 7 years with out any problems. I used to use Ioannis way at first and it worked as well.
    Thanks for the answer! I sometimes find small snippets or statements in the manual that leave me wondering about the actual functioning. In this case it was the DEFINE WRITE_INT 1. I found it mentioned but didn't see the explanation about how it worked. Thanks again to all. I can get back to programming now... maybe after another cup of coffee!

Similar Threads

  1. EEPROM Write command with interrupts??
    By Elnino in forum General
    Replies: 4
    Last Post: - 23rd November 2009, 07:44
  2. EEPROM write
    By Sach_1979 in forum General
    Replies: 2
    Last Post: - 23rd September 2009, 20:18
  3. Write to eeprom
    By mradde in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st February 2009, 19:27
  4. WRITE TO Eeprom
    By crhomberg in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 12th February 2008, 05:33
  5. Problems with 16F876 on interrupts an WRITE / READ
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2005, 15:38

Members who have read this thread : 0

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