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_program_memory

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







read_program_memory
PostPosted: Wed Jun 07, 2006 8:08 pm     Reply with quote

Hi, I was wondering if it was a fastest way to read the program memory than the function read_program_memory, that is pretty slow.
Any pieces of information would be really helpful,
Thanks,
Charles.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jun 07, 2006 8:38 pm     Reply with quote

Read the datasheet. It tells you how to read program memory.
Ttelmah
Guest







PostPosted: Thu Jun 08, 2006 2:48 am     Reply with quote

Unfortunately, it won't be much if any faster.
The architecture of the PIC, does not allow direct 'read' access to it's memory. Hence doing this, involves setting up the pointer registers, and then accessing the data through a seperate register.
If you only need to access single locations, then this can be done more efficiently using the 'read_program_eeprom' function, which just performs the basic read at one address. The 'read_program_memory' function is designed to fetch 'blocks', and therefore has the overhead associated with accessing a data array to put the results into.
If you look at the code generated:
Code:

....................   test=read_program_eeprom(0x000100L);
....................   test=read_program_eeprom(address);
0DC6:  MOVFF  2D,FF8
0DCA:  MOVFF  2C,FF7
0DCE:  MOVFF  2B,FF6  //transfer 'address' into the target registers
0DD2:  TBLRD*+
0DD4:  MOVF   FF5,W
0DD6:  TBLRD*
0DD8:  MOVFF  FF5,03
0DDC:  CLRF   FF8      //Move the data
0DDE:  MOVWF  29
0DE0:  MOVFF  03,2A  //Store it into the result


And compare with the data sheet listing to do the same job:
Code:

EXAMPLE 6-1: READING A FLASH PROGRAM MEMORY WORD

   MOVLW CODE_ADDR_UPPER ; Load TBLPTR with the base
   MOVWF TBLPTRU ; address of the word
   MOVLW CODE_ADDR_HIGH
   MOVWF TBLPTRH
   MOVLW CODE_ADDR_LOW
   MOVWF TBLPTRL
READ_WORD
   TBLRD*+ ; read into TABLAT and increment
   MOVF TABLAT, W ; get data
   MOVWF WORD_EVEN
   TBLRD*+ ; read into TABLAT and increment
   MOVF TABLAT, W ; get data
   MOVF WORD_ODD

The code is basically the same (except the compiler takes advantage of the single instruction moves offered on the larger PICs...).

Best Wishes
charles`
Guest







PostPosted: Thu Jun 08, 2006 12:18 pm     Reply with quote

Thank you very much for you help, i'll see what I can do.
-Charles.
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