|
|
View previous topic :: View next topic |
Author |
Message |
ck
Joined: 02 May 2012 Posts: 18
|
read write program memory PIC24 |
Posted: Fri Sep 21, 2012 7:14 am |
|
|
Hi everybody,
I feel so stupid because i can't write and read a simple variable in my PIC24HJ.
I notice that no EEPROM figure out but i can write in a flash memory.
Code: |
#define ROMCALOC 0x4000
#org ROMCALOC,0x4002 {}
|
in to the main
Code: |
int32 addr;
int8 data[2];
int8 data_r[2];
write_program_memory(addr,data,2); read_program_memory(addr,data_r,2);
|
why it does not work??
Thanks in advance. |
|
|
ck
Joined: 02 May 2012 Posts: 18
|
|
Posted: Mon Sep 24, 2012 3:36 am |
|
|
Firstly thanks for all answers.
I understood how flash works and here is the solution.
Code: |
#define CK_FLASH_END (getenv("PROGRAM_MEMORY")-1)
#define CK_FLASH_PAGE_SIZE (getenv("FLASH_ERASE_SIZE")/2)
#define CK_NUM_PAGES (CK_FLASH_END/CK_FLASH_PAGE_SIZE)
#define CK_USER_PAGE (CK_FLASH_PAGE_SIZE*(CK_NUM_PAGES-1))
#org CK_USER_PAGE,CK_FLASH_END {}
|
in main code:
Code: |
unsigned int8 read_data[8];
unsigned int8 write_data[] = {12,34,56,0,25,42,1,0};
write_program_memory(CK_USER_PAGE,write_data,8);
delay_ms(1);
read_program_memory(CK_USER_PAGE,read_data,8);
|
P.S:CCS 4.134 |
|
|
|
|
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
|