pic16f877 Datasheet help - Newbie Question

Status
Not open for further replies.

Tiwana6330

Member level 1
Joined
Feb 3, 2011
Messages
36
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,536
I have just started to read on the EEPROM & FLASH memory of PIC16F877. I could find the REGISTERS ASSOCIATED WITH DATA EEPROM/PROGRAM FLASH & range of addresses on which I can write data (0000h to 3FFFh for the PIC16F876/877). But I cannot find the partition of addresses between FLASH and EEPROM between this range.

Secondly, choosing between FLASH and EEPROM, what are the relative advantages and disadvantages? I know that I can store a 14 bit number on FLASH and 8 bit on EEPROM addressed, but is there any other difference.

Thanks
 
Last edited:





Hi,

The Flash memory is the area your program code is written into by the programmer, as such you do not normally have any other access to this memory.
Your 8K (14bits) Flash memory occupies 0x000 to 0x1FFF on the 877chip.

The EEprom is an area of memory your the Users progrqam can read and write data to.
The difference between the RAM memory and EEprom memory is that the data the EEprom is retained when power is removed fro the chip.

EEprom data can be written into the chip either at programming time or during your programs execution time.
There are examples in the Microchip datasheet of how to do this, its important you follow that code exactly for it to work properly.


Code:
***************************************************************************
; DECLARE EEPROM DATA
;
; preload EEPROM with base values  -at programming time
;

	org 0X2100
	de 0X09,0X59,0X50,0X49,0X60,0X70,0X55,0X40,0X80... etc
 

Thanks for the reply

The Flash memory is the area your program code is written into by the programmer, as such you do not normally have any other access to this memory.

Does it mean that during program execution we Cannot write to FLASH and only to to EEPROM?

Secondly, if Flash memory occupies 0x000 to 0x1FFF on the 877chip, what are the EEPROM addresses on which I can write data? Thanks for help
 

Does it mean that during program execution we Cannot write to FLASH and only to to EEPROM?

In simple terms Yes, you can only write to Flash program memory areas during programming time.
( there are expections to this for more unusal things like bootloaders etc )

EEPROM can be written to during programming by using that address and method I showed on the last reply.
It can also be read and written to during program execution.

Your DATA RAM areas are used for temporary User Registers / variables, while the chip is powered.
Its the User Registers that are the normal data work areas not EEPROM




Secondly, if Flash memory occupies 0x000 to 0x1FFF on the 877chip, what are the EEPROM addresses on which I can write data? Thanks for help

As metioned above from within the program code at programming time location ORG 0x2100 for that chip.
When reading or writing to EEprom during program execution you simply specify which of the 0 - 255 bytes you want to access, the system takes care of the location for you.
Again if you read the datasheet example you will see what I mean.

The 368 bytes of DATA RAM areas for your Users registers / variables are held across 4 'banks' of memory and to access each you need to specify which bank you are refering to if using Assembler; in higher languages the complier takes care of that for you.
 
In simple terms Yes, you can only write to Flash program memory areas during programming time.
( there are expections to this for more unusal things like bootloaders etc )

I am using Hitech C and in pic.h header file, there is a subroutine defined to read and write on FLASH during program execution. Is it using some bootloader? The code is below

 

Hi,

Sorry cannot help you with that code as I only do Assembler.

Sure some other forum member will come in and help you with it .....
 


You can see in PICKit Programmer both them seperate and also in MPLAB "Veiw MEMORY".





I think some of the PICs like PIC16F886 new version replacing all PIC16F87x has Program memory Read/Write during run time. Please refer to PIC16F886 Datasheet. In short all those chip has self write of Flash ROM cna be read/written during run time.

Hope this helps you.

Thankyou

---------- Post added at 14:35 ---------- Previous post was at 14:22 ----------


Here is the EEPROM Adr for PIC16F877

 

Hope this helps you.

Thankyou

Sure it has helped alot. Thanks a million. Just a few more things. I have written a small code.


void main(void)
{
EEPROM_WRITE(1,"ABC");
for(;;
}

where EEPROM_WRITE is a function defined in pic.h. The I selected MPLAB SIM and ran the simulation - halted the sim and viewed the EEPROM. The Memory Address 00,01 shows 24. Thats not what I expected. What am I doing wrong? Thanks for help
 


You have to look in eeprom_routine.h not pic.h(defines only about chip). Second it has to be like this EEPROM_WRITE(addr, value) where addr = 01 and values = int value.

Thankyou

PS. eeprom_routine is found in your hitech installation software under include folder.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…