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

read write program memory PIC24

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



Joined: 02 May 2012
Posts: 18

View user's profile Send private message

read write program memory PIC24
PostPosted: Fri Sep 21, 2012 7:14 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Sep 24, 2012 3:36 am     Reply with quote

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