Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

PIC16C84 Internals Questions

Status
Not open for further replies.

stameni

Computer
Nov 15, 2001
9
I have been reading parts of the PIC16C84 datasheet. Unfortunately, I have not got the whole document and so I use 16F8X's, which seems pretty similar. However, some parts aren't extremely clear. Could anyone explain the following?

1. What are the differences between the Data EEPROM and Flash Program Memory? I think Data is 8-bit wide and Flash should be made of 14-bit memory words, but I'm not sure. I also don't know how to write in Program Memory (when considering chips which have Flash, not ROM): using an
EPROM programmer, or…? Writing to Data EEPROM is done in a way I could understand, but to a Flash Program Mem?

2. When an interrupt occurs, is it necessary to reset the GIE flag (INTCON<7>) manually, or this is done implicitly? According to the PIC16F8X datasheet it isn't necessary, but what about PIC16C84? I think it is done implicitly, but some people told me that it had to be done as a first instruction in an interrupt service routine.

Thank you all. Sorry if my questions are too easy.

Best wishes,
Ivan
 
Replies continue below

Recommended for you

Hi,

The flash memory is the program memory thats why its 14 bit. During normal program execution it can not be written to. You can only write to it when programming the device through a programmer.

The EEPROM however allows you to write data to it uch the same as the RAM on the chip except its a little more complicated. The advantage being that you don't loose the data if the power fails if its in EEPROM.

The disadvantage is that the EEPROM has a limited number of write cycles (I think 1,000,000) so its not to be used as a general variable location like RAM during normal program execution.

As for the interrupts. I would definitely not reset it as a first instruction in a handler. In fact after pushing the varies registers/variable on the stack my first instruction is to disable global interrupts. (Who wants to be interrupted whilst carrying out an interrupt !!).
When an interrupt is reponded to the GIE is cleared anway but like I said check and if its not, then clear it as soon as possible in your handler.

The last thing you should do is set it.

As for not having a 16C84 data sheet see :-
Check out page 44 on the GIE and what to do whilst reading the above link.

Any help ?, yes no let me know.

Regards
 
Hello,

Thank you for explaining the differences between Flash and EEPROM memory. However, I'm still a bit confused about the interrupts.

According to 30430C (for PIC16F8X controllers), page 48:
&quot;When an interrupt is responded to; the GIE bit is cleared to disable any further interrupt&quot;
and also:
&quot;The &quot;return from interrupt&quot; instruction, RETFIE, exits interrupt routine as well as sets the GIE bit, which re-enable interrupts.&quot;

It seems there is no need to test if GIE is set / cleared, and to perform an appropriate action both on the beginning and the end of the interrupt handler, because hardware (firmware, chip) does the job. I haven't checked out a link you mentioned, but I expect there is no difference with PIC16C84. The printed parts I have are at least 90% made with copy&paste technique from the same source :). However, I'll do something…

The reason why the controller works that way is probably to simplify programming, and also, which is more important, not to allow an another interrupt to occur while the handler runs (which may be overridden if there is a need). In my opinion, of course…

Ivan
 
Hi,

What you say is true for the 16C84 as well.

As I said in my previous post
When an interrupt is reponded to the GIE is cleared anway but like I said check and if its not, then clear it as soon as possible in your handler

Interrupts can be funny things as God only knows when they're going to occur and what your program was doing at the time.Unless your really strapped for code space or time there is no harm in adopting a belts and braces approach.

Yes it clears the GIE during an interrupt and resets it when you return from the handler. My point is set/clear them anyway that way any clitch in the hardware will be compensated by your code.

I have written a few handlers in my time and I have on a few occasions had a few unexpected results. so like I said if your short on space or time then let the hardware do it. If you can put it in code as well.

Any help ?, yes no let me know.

Regards
 
Actually, the main difference between Flash and EEPROM is how you erase/program the memory. An EEPROM, you can erase or program a single byte/word (depending on the device) at a time. A Flash device can program a single byte/word but must erase an entire block at a time. The block size for Flash varies depending on the device. Of course other variables like programming voltage, programming time, device speed, etc., should be considered.

Hope this helps!
 
Hello, melone,

Does it mean that if I wrote first time to a first EEPROM location, then to a second, then to a third, etc., and repeating this continuously, actually I should have (PIC16C84) 64 * 1,000,000 EEPROM WRITE cycles? In other words, do EEPROM locations not &quot;wear out&quot; equally?

It seems that I have 1,000,000 WRITE cycles for each EEPROM location?

Best wishes,
Ivan
 
Hi,

In response to melone. Actually in the context of just plain memory then the difference between Falsh & EEPROM are as you say. However in the context of the PIC16F84 the difference is being able to program the EEPROM during runtime and the FLASH memory only during the programming sequence.

In later devices (16F877) this is not true. You are able to write to the flash memory during program execution so in effect it can reprogram itself. (Although it does require a bit of knowhow). This has led to boot header programs for these devices.

But like I said previously the difference in the 16F84 is when you have ability to program the different types of memory.

As for your comment Stameni, The amount of write cycles you can have is for each cell. So if you write to them at a different frequency then YES they will 'wear' out unequally. I did see a program once which wrote to the location sequentially i.e. strating at pos 1 and increasing each time the program wrote to EEPROM. This had the effect of spreading out the 'wear' across all the EEPROM cells. Of course the programming over head is therefore greater in order to manage this.
Any help ?, yes no let me know.

Regards
 
I AM SEARCHING FOR THE PROGRAM LANGUAGE REQUIRED TO PROGRAM IN THE CALCULATION REQUIREMENTS TO PERFORMING ADDITION,SUBTRACTION,MULTIPLICATION, AND DIVISION WITHIN THE PIC 16F84
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor