|
|
View previous topic :: View next topic |
Author |
Message |
Angelo
Joined: 06 Oct 2006 Posts: 6 Location: Russia
|
Don't read flash memory PIC18F452 |
Posted: Wed Oct 18, 2006 9:19 am |
|
|
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
|
|
Posted: Wed Oct 18, 2006 9:38 am |
|
|
Hint.
What is the highest program memory address implemented in a 18F452.....
Best Wishes |
|
|
Angelo
Joined: 06 Oct 2006 Posts: 6 Location: Russia
|
|
Posted: Wed Oct 18, 2006 10:12 am |
|
|
Excuse me, but I haven't understood that you want to tell by it
It don't working even if to take 0xFF00 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 18, 2006 11:10 am |
|
|
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
|
|
Posted: Wed Oct 18, 2006 10:37 pm |
|
|
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?!
But why this doesn't work in Proteus?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Thu Oct 19, 2006 5:48 am |
|
|
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
|
|
Posted: Thu Oct 19, 2006 8:56 am |
|
|
Thank you |
|
|
|
|
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
|