CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

memory organization

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Allen
Guest







memory organization
PostPosted: Fri Aug 29, 2003 12:19 pm     Reply with quote

hi guys,
I'm a newbie of pic micro chip and I have the following question with pic16f877 (mplab 6.2 IDE, pcm 3.174).

I'm still pretty confused about the memory organization of pic16f877 after reading the datasheet!

As I understand, the memory are divided into program memory which stores the code(hex file <- correct me if i am wrong), and "data memory" which further broken down into general purpose ram and SFR (what about EEPROM?).

The part I don't understand is the EEPROM and SRAM data memory, are they mix up into a one "data memory" as mentioned above which contains the general purpose ram and SFR or I can access the general purpose ram and SFR with the address noted on data sheet and I could also access a sperated EEPROM data memory with address from 00h to FFh(256k)???

The #rom could let us insert data into a specific address range of memory, and #org could help us to protect it without being us by compiler. In the example (found on the forum, thanks for sharing) below, it inserted data into the "general purpose data memory", "SRAM", or "EEPROM" with pic16f877??

#include <16F877.h>
#device ICD=TRUE
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)

void main()
{


while(1){
printf("In while loop\r");
output_low(PIN_B1);
output_high(PIN_B1);
delay_ms(1000);
}
}

#org 0x1800, 0x18FF
#rom 0x1800 = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
#rom 0x1820 = {"1234567890"}
#rom 0x1830 = {"This is a test"}

If available, could you guys show me a big picture how the SRAM, EEPROM organize and rather the general purpose data memory and SFR located at SRAM or EEPROM??
And I need the address range for EEPROM and SRAM if they are sperated or mixed.

thanks for your help in advance.

Allen

___________________________
This message was ported from CCS's old forum
Original Post ID: 144517437
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: memory organization
PostPosted: Fri Aug 29, 2003 12:58 pm     Reply with quote

:=hi guys,
:=I'm a newbie of pic micro chip and I have the following question with pic16f877 (mplab 6.2 IDE, pcm 3.174).
:=
:=I'm still pretty confused about the memory organization of pic16f877 after reading the datasheet!
:=
:=As I understand, the memory are divided into program memory which stores the code(hex file <- correct me if i am wrong), and "data memory" which further broken down into general purpose ram and SFR (what about EEPROM?).
:=

Yes, that's right. Program memory, data memory, and data
eeprom are all separate.


:=The part I don't understand is the EEPROM and SRAM data memory, are they mix up into a one "data memory" as mentioned above which contains the general purpose ram and SFR or I can access the general purpose ram and SFR with the address noted on data sheet and I could also access a sperated EEPROM data memory with address from 00h to FFh(256k)???

They are separate. The "EEPROM" is called "data EEPROM"
in the Microchip data sheets. It's a slow-speed (5 ms or more,
to write to it), non-volatile memory. You cannot access
the data EEPROM with direct addressing when your PIC program
is running. See below.

:=
:=The #rom could let us insert data into a specific address range of memory, and #org could help us to protect it without being us by compiler. In the example (found on the forum, thanks for sharing) below, it inserted data into the "general purpose data memory", "SRAM", or "EEPROM" with pic16f877??
:=

The #rom statements below are inserting data into Program
memory.

If you wanted to use a #rom statement to insert data into
EEPROM data memory, then you would set the address somewhere
in the range of 0x2100 to 0x21FF. That's the address range of
the data EEPROM. But, you only access it this way during
programming. You can't access it that way when the PIC
is running. You have to follow the procedure given in the
PIC's data sheet, or with CCS, use the write_eeprom() and
read_eeprom() functions.

:=#include <16F877.h>
:=#device ICD=TRUE
:=#fuses HS, NOWDT, NOPROTECT, NOLVP
:=#use delay(clock = 4000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)
:=
:=void main()
:={
:=
:=
:=while(1){
:= printf("In while loop\r");
:= output_low(PIN_B1);
:= output_high(PIN_B1);
:= delay_ms(1000);
:= }
:=}
:=
:=#org 0x1800, 0x18FF
:=#rom 0x1800 = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
:=#rom 0x1820 = {"1234567890"}
:=#rom 0x1830 = {"This is a test"}
:=
:=If available, could you guys show me a big picture how the SRAM, EEPROM organize and rather the general purpose data memory and SFR located at SRAM or EEPROM??

You should find the memory map in the 16F877 data sheet.
The only thing they won't show is the address of the data
EEPROM. You have to get from the programming specification,
which is a separate document. Go to Engineer's toolbox
on the Microchip website, and you'll be able to find it.

:=And I need the address range for EEPROM and SRAM if they are separated or mixed.
:=

___________________________
This message was ported from CCS's old forum
Original Post ID: 144517438
Allen
Guest







thanks PCM programmer...
PostPosted: Fri Aug 29, 2003 2:14 pm     Reply with quote

:=:=hi guys,
:=:=I'm a newbie of pic micro chip and I have the following question with pic16f877 (mplab 6.2 IDE, pcm 3.174).
:=:=
:=:=I'm still pretty confused about the memory organization of pic16f877 after reading the datasheet!
:=:=
:=:=As I understand, the memory are divided into program memory which stores the code(hex file <- correct me if i am wrong), and "data memory" which further broken down into general purpose ram and SFR (what about EEPROM?).
:=:=
:=
:=Yes, that's right. Program memory, data memory, and data
:=eeprom are all separate.
:=
:=
:=:=The part I don't understand is the EEPROM and SRAM data memory, are they mix up into a one "data memory" as mentioned above which contains the general purpose ram and SFR or I can access the general purpose ram and SFR with the address noted on data sheet and I could also access a sperated EEPROM data memory with address from 00h to FFh(256k)???
:=
:=They are separate. The "EEPROM" is called "data EEPROM"
:=in the Microchip data sheets. It's a slow-speed (5 ms or more,
:=to write to it), non-volatile memory. You cannot access
:=the data EEPROM with direct addressing when your PIC program
:=is running. See below.
:=
:=:=
:=:=The #rom could let us insert data into a specific address range of memory, and #org could help us to protect it without being us by compiler. In the example (found on the forum, thanks for sharing) below, it inserted data into the "general purpose data memory", "SRAM", or "EEPROM" with pic16f877??
:=:=
:=
:=The #rom statements below are inserting data into Program
:=memory.
:=
:=If you wanted to use a #rom statement to insert data into
:=EEPROM data memory, then you would set the address somewhere
:=in the range of 0x2100 to 0x21FF. That's the address range of
:=the data EEPROM. But, you only access it this way during
:=programming. You can't access it that way when the PIC
:=is running. You have to follow the procedure given in the
:=PIC's data sheet, or with CCS, use the write_eeprom() and
:=read_eeprom() functions.
:=
:=:=#include <16F877.h>
:=:=#device ICD=TRUE
:=:=#fuses HS, NOWDT, NOPROTECT, NOLVP
:=:=#use delay(clock = 4000000)
:=:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)
:=:=
:=:=void main()
:=:={
:=:=
:=:=
:=:=while(1){
:=:= printf("In while loop\r");
:=:= output_low(PIN_B1);
:=:= output_high(PIN_B1);
:=:= delay_ms(1000);
:=:= }
:=:=}
:=:=
:=:=#org 0x1800, 0x18FF
:=:=#rom 0x1800 = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
:=:=#rom 0x1820 = {"1234567890"}
:=:=#rom 0x1830 = {"This is a test"}
:=:=
:=:=If available, could you guys show me a big picture how the SRAM, EEPROM organize and rather the general purpose data memory and SFR located at SRAM or EEPROM??
:=
:=You should find the memory map in the 16F877 data sheet.
:=The only thing they won't show is the address of the data
:=EEPROM. You have to get from the programming specification,
:=which is a separate document. Go to Engineer's toolbox
:=on the Microchip website, and you'll be able to find it.
:=
:=:=And I need the address range for EEPROM and SRAM if they are separated or mixed.
:=:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517439
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group