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 CCS Technical Support

Don't read flash memory PIC18F452

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



Joined: 06 Oct 2006
Posts: 6
Location: Russia

View user's profile Send private message

Don't read flash memory PIC18F452
PostPosted: Wed Oct 18, 2006 9:19 am     Reply with quote

Help me, i don't know because not read flash memory, how i wanted:
Flash memory after being erased: FF FF FF FF FF FF FF FF
Flash memory after being written: 01 02 03 04 05 06 07 08
in real:
Flash memory after being erased: FF FF FF FF FF FF FF FF
Flash memory after being written: FF FF FF FF FF FF FF FF

This example i took from
http://ccsinfo.com/forum/viewtopic.php?t=28440&start=0&postdays=0&postorder=asc&highlight=write+program+programme+memory&sid=d5adb69c5bbddde1838170e4259da4c5
Code:

#include <18F452.h>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP, NOPROTECT, CPB
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define ROM_ADDR  0x4000

//====================================
void main(void)
{
int8 i;
int8 write_data[8] = {1,2,3,4,5,6,7,8};
int8 read_data[8]  = {0,0,0,0,0,0,0,0};

printf("Flash write size = %u\n\r", getenv("FLASH_WRITE_SIZE"));
printf("\n\r");

// Erase flash memory.
erase_program_eeprom(ROM_ADDR);

// Read flash memory.
read_program_memory(ROM_ADDR, read_data, sizeof(read_data));

// Display it, to show it's erased.
printf("Flash memory after being erased: ");
for(i = 0; i < sizeof(read_data); i++)
    printf("%X ", read_data[i]);
printf("\n\r");
printf("\n\r");

// Now write 8 bytes.
write_program_memory(ROM_ADDR, write_data, sizeof(write_data));

// Read them back.
read_program_memory(ROM_ADDR, read_data, sizeof(read_data));

// Display data read from Flash memory.
printf("Flash memory after being written: ");
for(i = 0; i < sizeof(read_data); i++)
    printf("%X ", read_data[i]);
printf("\n\r");
printf("\n\r");

while(1);
}
Ttelmah
Guest







PostPosted: Wed Oct 18, 2006 9:38 am     Reply with quote

Hint.
What is the highest program memory address implemented in a 18F452.....

Best Wishes
Angelo



Joined: 06 Oct 2006
Posts: 6
Location: Russia

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 10:12 am     Reply with quote

Excuse me, but I haven't understood that you want to tell by it Sad
It don't working even if to take 0xFF00
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 11:10 am     Reply with quote

Are you using an 18F452 ? I ran that code just now, on a PicDem2-Plus
board and it worked OK.

The 18F452 has ROM memory from 0x0000 to 0x7FFF.
The program writes to 8 bytes of ROM memory at 0x4000.
This is in the middle of the available ROM address range.

If you are using 18F242 or 18F442, the program won't work.
Those PICs only have ROM from 0x0000 to 0x3FFF.

What PIC are you using ?

I have another question. Are you doing this on real hardware,
or is this a Proteus project ?
Angelo



Joined: 06 Oct 2006
Posts: 6
Location: Russia

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 10:37 pm     Reply with quote

PCM programmer wrote:
I have another question. Are you doing this on real hardware,
or is this a Proteus project ?


Yes i've tested in Proteus, i thought it's will work there?! Sad
But why this doesn't work in Proteus?
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 11:17 pm     Reply with quote

Since it works in hardware, I think it's a Proteus problem.
Here's a thread on it in the Proteus forum. One person says it
doesn't work. Another one says it does.
http://support.labcenter.co.uk/forum/viewtopic.php?t=231&highlight=18f452

I suggest that you ask a question on that thread. Tell them your
version of Proteus and explain that it works OK in hardware.
Ask why doesn't it work with Proteus.

Here's the main page for the Proteus VSM forum:
http://support.labcenter.co.uk/forum/viewforum.php?f=9
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu Oct 19, 2006 5:48 am     Reply with quote

For unlicensed users of Proteus, the program is designed to work incorrectly and make life difficult for unregistered users. I've helped out a few people on it, and the root cause of the problem was they were using unregistered copies.

If you are using the licensed version, then contact Labcenter with your problem. However, I've simulated reading and writing from flash memory many times with a PIC18F452 in the past, and it simulates fine.
Angelo



Joined: 06 Oct 2006
Posts: 6
Location: Russia

View user's profile Send private message

PostPosted: Thu Oct 19, 2006 8:56 am     Reply with quote

Thank you
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