Searching \ for 'Waking the 16F877 after EEPROM write' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/memory.htm?key=eeprom
Search entire site for: 'Waking the 16F877 after EEPROM write'.

Truncated match.
PICList Thread
'Waking the 16F877 after EEPROM write'
2000\04\16@190802 by Josh Koffman

flavicon
face
Greetings,
I am going to be using the EEPROM on the 16F877 for the first time and
I'm somewhat confused by the data book about putting the microcontroller
to sleep during an EEPROM write cycle. Basically my question is, can I
put the microcontroller to sleep, and have the EEIE EEPROM Write
interrupt wake the microcontroller up, but not vector to 0x04? I just
want code execution to continue from the instruction after the sleep
command. The book seems somewhat confusing, but if I disable Global
Interrupts <INTCON:7> and enable the EEPROM Write Operation Interrupt
<PIE2:4> will this accomplish what I describe? Will I need to enable
Peripheral Interrupts <INTCON:6>?
I am not using interrupts anywhere else in my program so I'd like to
stay away from them if possible. If there is no way to wake the
microcontroller without having it vector to 0x04, can I just have RETFIE
as the only instruction in my interrupt routine and have it accomplish
what I need? I know the book says something about all this, but it seems
so unclear. It is on page 134 - Section 12.13.2 Wake-up Using
Interrupts, of the PIC16F87X Data Book.
Any and all help is appreciated! Thank you in advance!

Josh Koffman
spam_OUTjoshyTakeThisOuTspammb.sympatico.ca

2000\04\17@001646 by Sebastian Garcia

flavicon
face
Hi Josh,

-----Original Message-----
From: Josh Koffman <.....joshyKILLspamspam@spam@MB.SYMPATICO.CA>


|Greetings,
|I am going to be using the EEPROM on the 16F877 for the first time and
|I'm somewhat confused by the data book about putting the microcontroller
|to sleep during an EEPROM write cycle. Basically my question is, can I
|put the microcontroller to sleep, and have the EEIE EEPROM Write
|interrupt wake the microcontroller up, but not vector to 0x04?

Yes,

|I just
|want code execution to continue from the instruction after the sleep
|command. The book seems somewhat confusing, but if I disable Global
|Interrupts <INTCON:7> and enable the EEPROM Write Operation Interrupt
|<PIE2:4> will this accomplish what I describe? Will I need to enable
|Peripheral Interrupts <INTCON:6>?

Disable GIE (global interrupt), enable EEIE (e2prom interrupt), and enable
PEIE (peripheral interrupt). This way, with GIE disabled, the PIC wake up
executing the next instruction after the SLEEP instruction.

|I am not using interrupts anywhere else in my program so I'd like to
|stay away from them if possible.

Why?

|If there is no way to wake the
|microcontroller without having it vector to 0x04, can I just have RETFIE
|as the only instruction in my interrupt routine and have it accomplish
|what I need?

I've never done that, but I think it should work (two instructions: first
clear the EEIF bit by software, then RETFIE).

|I know the book says something about all this, but it seems
|so unclear. It is on page 134 - Section 12.13.2 Wake-up Using
|Interrupts, of the PIC16F87X Data Book.
|Any and all help is appreciated! Thank you in advance!
|
|Josh Koffman
|joshyspamKILLspammb.sympatico.ca

Best Regards,

S.-

2000\04\17@010733 by Josh Koffman

flavicon
face
Thank you for the quick reply Sebastian!


> |I just
> |want code execution to continue from the instruction after the sleep
> |command. The book seems somewhat confusing, but if I disable Global
> |Interrupts <INTCON:7> and enable the EEPROM Write Operation Interrupt
> |<PIE2:4> will this accomplish what I describe? Will I need to enable
> |Peripheral Interrupts <INTCON:6>?
>
> Disable GIE (global interrupt), enable EEIE (e2prom interrupt), and enable
> PEIE (peripheral interrupt). This way, with GIE disabled, the PIC wake up
> executing the next instruction after the SLEEP instruction.

Great! This is what I suspected, but the only reference I found in the book
kept mentioning when the interrupt flag bit was set. I knew the bit wouldn't
be set because the EEPROM wouldn't be finished writing.


>
> |I am not using interrupts anywhere else in my program so I'd like to
> |stay away from them if possible.
>
> Why?

Well, I made that choice for a couple of reasons. First, I am still relatively
new to PIC programming and this will be a rather large project for me. I am
implementing many new things that I have never used before. Second, should
this project be successful, I will hopefully expand on it in the future, and
at that point I may need to use interrupts. If I can keep everything going
without interrupts right now, I feel it will be slightly cleaner should I ever
need to write an interrupt handler. But above all, I don't need them...why use
them when all I need is to wake up the microcontroller?

>
> |If there is no way to wake the
> |microcontroller without having it vector to 0x04, can I just have RETFIE
> |as the only instruction in my interrupt routine and have it accomplish
> |what I need?
>
> I've never done that, but I think it should work (two instructions: first
> clear the EEIF bit by software, then RETFIE).

I was pretty sure this method would work too, but it seems such a waste of
code. All I need is for the controller to wake up...I know where the interrupt
will be from, and I know that all I will want to do is continue code
execution. I suppose i wanted a more elegant solution than the "Clear the
interrupt bit, then RETFIE" solution. :)

Thank you again!

Josh Koffman
.....joshyKILLspamspam.....mb.sympatico.ca

2000\04\17@121434 by Tom Handley

picon face
  Josh, the example code on page 43 works exactly as described but they
don't provide the whole picture as far as the SLEEP Interrupt. If you do not
want to use interrupts, you can simply replace SLEEP with a 10ms (or longer)
delay. However, the most efficient and reliable method is the one they
describe. Execution is resumed right after the SLEEP interrupt.

  You need to do the following:

     1. Set INTCON Bit 6 to enable Peripheral Interrupts.
     2. Set PIE2 Bit 4 (EEIE) to Enable "EEPROM Write Operation Interrupt".
        Note, this register is in bank 1 (RP1 = 0, RP0 = 1).

  In your Interrupt Handler, look for PIR2 Bit 4 (EEIF) which is the
"Write Operation Interrupt" flag Bit. As with most interrupt flags, you
need to clear the Bit. Note, PIR2 is in bank 0 (RP1 = 0, RP0 = 0).

  That's it. Works fine, everytime...

  - Tom

At 05:45 PM 4/16/00 -0500, Josh Koffman wrote:
{Quote hidden}

------------------------------------------------------------------------
Tom Handley
New Age Communications
Since '75 before "New Age" and no one around here is waiting for UFOs ;-)

2000\04\17@130918 by Josh Koffman

flavicon
face
Tom Handley wrote:

>    Josh, the example code on page 43 works exactly as described but they
> don't provide the whole picture as far as the SLEEP Interrupt. If you do not
> want to use interrupts, you can simply replace SLEEP with a 10ms (or longer)
> delay. However, the most efficient and reliable method is the one they
> describe. Execution is resumed right after the SLEEP interrupt.
>
>    You need to do the following:
>
>       1. Set INTCON Bit 6 to enable Peripheral Interrupts.
>       2. Set PIE2 Bit 4 (EEIE) to Enable "EEPROM Write Operation Interrupt".
>          Note, this register is in bank 1 (RP1 = 0, RP0 = 1).
>
>    In your Interrupt Handler, look for PIR2 Bit 4 (EEIF) which is the
> "Write Operation Interrupt" flag Bit. As with most interrupt flags, you
> need to clear the Bit. Note, PIR2 is in bank 0 (RP1 = 0, RP0 = 0).
>
>    That's it. Works fine, everytime...
>
>    - Tom

Tom,
Thank you for the response. My original intention was to avoid using the
interrupt handler. I'm not using interrupts elsewhere in my application, and the
handler would have basically just cleared the interrupt flag, then RETFIE. I
thought this was somewhat of a waste. I got another response, and I'm pretty
sure what I can do is enable peripheral interrupts, enable the EEPROM interrupts
(EEIE), but leave GIE disabled. When I put the microcontroller to sleep, and the
write completes, the interrupt will wake the controller up, but not cause it to
vector to 0x04. Am I correct in saying this will happen?

Thanks for all your help!

Josh Koffman
joshyspamspam_OUTmb.sympatico.ca

2000\04\18@090216 by Tom Handley

picon face
  Josh, this has been an interesting topic. Looking back over the data book,
it appears that you can wakeup from SLEEP by just setting the related enable
Bit (EEIE in this case). If GIE is cleared, execution will continue right
after the SLEEP and will not jump to the IRQ address. Since I normally use
interrupts for other things I was not aware of this alternative. Note, you
still need to clear the Flag Bit (EEIF) after you wakeup. So regarding my
earlier remarks, "nevermind" ;-)

  - Tom

At 11:56 AM 4/17/00 -0500, Josh Koffman wrote:
>Tom Handley wrote:
>
>>    Josh, the example code on page 43 works exactly as described but they
>> don't provide the whole picture as far as the SLEEP Interrupt. If you do
not
>> want to use interrupts, you can simply replace SLEEP with a 10ms (or
longer)
>> delay. However, the most efficient and reliable method is the one they
>> describe. Execution is resumed right after the SLEEP interrupt.
>>
>>    You need to do the following:
>>
>>       1. Set INTCON Bit 6 to enable Peripheral Interrupts.
>>       2. Set PIE2 Bit 4 (EEIE) to Enable "EEPROM Write Operation
Interrupt".
{Quote hidden}

and the
>handler would have basically just cleared the interrupt flag, then RETFIE. I
>thought this was somewhat of a waste. I got another response, and I'm pretty
>sure what I can do is enable peripheral interrupts, enable the EEPROM
interrupts
>(EEIE), but leave GIE disabled. When I put the microcontroller to sleep,
and the
>write completes, the interrupt will wake the controller up, but not cause
it to
>vector to 0x04. Am I correct in saying this will happen?
>
>Thanks for all your help!
>
>Josh Koffman
>@spam@joshyKILLspamspammb.sympatico.ca

------------------------------------------------------------------------
Tom Handley
New Age Communications
Since '75 before "New Age" and no one around here is waiting for UFOs ;-)

2000\04\18@150126 by Josh Koffman

flavicon
face
Tom Handley wrote:

>    Josh, this has been an interesting topic. Looking back over the data book,
> it appears that you can wakeup from SLEEP by just setting the related enable
> Bit (EEIE in this case). If GIE is cleared, execution will continue right
> after the SLEEP and will not jump to the IRQ address. Since I normally use
> interrupts for other things I was not aware of this alternative. Note, you
> still need to clear the Flag Bit (EEIF) after you wakeup. So regarding my
> earlier remarks, "nevermind" ;-)
>
>    - Tom
>

Tom,
Thank you! This is what I had figured would happen, but I wanted to be sure.
Eventually I'm sure I will need interrupts in this application, in which case I
will need to add some handling. For now however, I'm trying to use the KISS
principal. I'm still somewhat new to PIC programming, and when I design something
and it doesn't work, often I cannot figure out why and end up abandoning the
project. Anyways, Thank you very much for your help!

Josh Koffman
KILLspamjoshyKILLspamspampangea.ca

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...