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

18f4455 Table read problem

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



Joined: 10 Oct 2004
Posts: 21
Location: UK

View user's profile Send private message Yahoo Messenger MSN Messenger

18f4455 Table read problem
PostPosted: Tue Jun 28, 2005 4:48 am     Reply with quote

Hi, i could do with some help with my latest project i am using PCWH 3.222 and the problem is i need to create a table in c some thing like :

char const temp[8] =
{0b00111000,
0b00111100,
0b00111000,
0b00111100,
0b00111000,
0b00111100,
0b00111000,
0b00111100};

and i need to be able to read it using the TBLRD*+ in asembler like

#ASM
TBLRD*+
movff TABLAT, PORTb
#ENDASM

i know that i have to point TBLPTR to the address of the table and you cant use a pointer to a constant but after reading the previous posts on this subject i am still none the wiser.
Can any one give me some example code that creates a table as above and uses a variable to hold the address of the table, puts that address in to TABLAT and then uses an assembler loop to read the whole table and asign the value to PORTb one by one, i know its a lot to ask but iv been stuck on this for about a week now any its getting frustraiting

Kind regards

Michael Dale
asmallri



Joined: 12 Aug 2004
Posts: 1636
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Jun 28, 2005 5:15 am     Reply with quote

Here is an example of doing it with an EEPROM. It is the same mechanism for Program memory just chainging the address.


Code:

#define EEPROM      0xf00000
#define E_Priority   0x00      // SMS Telephone Number Priority
#define E_SMS0      0x10                     // Index 0 SMS Number
#define E_SMS1      E_SMS0 + SMS_Number_Length+1    // Index 1 SMS Number
#define E_SMS2      E_SMS1 + SMS_Number_Length+1   // Index 2 SMS Number
#define E_SMS3      E_SMS2 + SMS_Number_Length+1   // Index 3 SMS Number

#rom EEPROM + E_Priority = {"\2\1\0\3"}
#rom EEPROM + E_SMS3    = {"0123456789"}
#rom EEPROM + E_SMS2    = {"0419204802"}

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Mark



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

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

PostPosted: Tue Jun 28, 2005 6:13 am     Reply with quote

See this post from PCM Programmer about using label_address().
http://www.ccsinfo.com/forum/viewtopic.php?t=20616&highlight=label
You can then load that value into the TBLPTR regs and do what you want.
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