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

eeprom reading

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







eeprom reading
PostPosted: Fri Aug 29, 2003 3:12 pm     Reply with quote

Hi guys,
I have following code to test my eeprom data with 16f877 (mplab 6.2).
However, I cann't read the data from the eeporm window, all the data shown are FF.
Do i have to make any setting in order to config the eeprom window show the right address range (0x2100 - 21FF)??

#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)

void main()
{
int i;
byte temp;
while(1){
printf("In while loop\r");
output_low(PIN_B1);
delay_ms(1000);
output_high(PIN_B1);


temp = read_eeprom(0x2100);
printf("2100 data is \%u", temp);
}
}
#ROM 0x2100 = {
0x18, //addr offset: 00
0x00, //addr offset: 01
0x90, //addr offset: 02
}

Also,is it reading /writting data from sram is fater than eeprom, if so, what is the address range for sram.
what about wiritting data into program memory? is it faster than sram, eeprom, and how can i insert data in program memory (i mean data not the source code)

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: eeprom reading
PostPosted: Fri Aug 29, 2003 3:23 pm     Reply with quote

Here is a demo program that you should try.

When you program the HEX file into the PIC, make sure that
your programmer is enabled for writing to EEPROM.

On many programmers (such as PicStart-Plus with MPLAB),
there is a separate "check box" that must be selected
to allow writing data to the internal EEPROM.

If you do that, the following program should work.

<PRE>
//-------------------------------------------------------------
// INCLUDE FILES
<BR>
#include "16f877.h"
<BR>
//-------------------------------------------------------------
// COMPILER DIRECTIVES
<BR>
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use Delay(Clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
<BR>
#rom 0x2100 = {'H','E','L','L','O',' ','T','H','E','R','E'}
<BR>
//============================================================

main()
{
char value;
char addr;
<BR>
// Read back the internal eeprom and display the results.
<BR>
for(addr = 0; addr < 11; addr++)
{
value = read_eeprom(addr);
printf("\%x ", value);
}
printf("\n\r");
<BR>
while(1);
}
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517441
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