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

DA instruction in ASM with CCS ?

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



Joined: 18 Aug 2006
Posts: 6

View user's profile Send private message

DA instruction in ASM with CCS ?
PostPosted: Thu Aug 24, 2006 8:55 am     Reply with quote

Hi,

When you're programming in assembler language, you can use the instruction "DA B'0110001101' " for example to initialize an array in flash memory and reading it after that at run time.

You're doing it like that for example :

File mydata.inc :

ORG mydata
DA B'0110001101'
DA B'0110001101'
DA B'0110001101'
DA B'0110001101'

And in your asm programm, you include the file mydata.inc and mark the start of your array by adding a label mydata at the end of your asm programm.

So, your datas are set in flash when you load your programm and finally you just need to read them after that in your programm.

So I'd like to know if you can use this instruction too with CCS compiler because I tested it but it didn't work... Or is there another CCS instruction which could serve the same purpose ?

My goal is to really access flash directly at loading time, not to use the word "const" with an array of C type. Smile

Thank you,
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 24, 2006 9:40 am     Reply with quote

Have a look at http://www.ccsinfo.com/forum/viewtopic.php?t=23914
Akutabi



Joined: 18 Aug 2006
Posts: 6

View user's profile Send private message

PostPosted: Fri Aug 25, 2006 2:39 am     Reply with quote

Thank you,

However I think I'll need to use a C type array because I can't do it the way I wanted it to work.

In fact I wanted to do it like that :

File : main.c

#include "datas.h"

void main(void)
{
while(1);

#ASM
DataValues:
#ENDASM
}

File : datas.h

#ROM DataValues =
{
0,
1,
2,
3,
4,
5
}

But the compiler doesn't succeed in finding DataValues label and since I need my datas to be in a separate file, it doesn't work... :(
Akutabi



Joined: 18 Aug 2006
Posts: 6

View user's profile Send private message

PostPosted: Fri Aug 25, 2006 3:13 am     Reply with quote

Finally I decided to define the start of the array myself but the reading doesn't work...

#define ARRAY 0x06D9

#ROM ARRAY = {0,1,2,3,4,5}

void main(void)
{
int16 data;

data = read_program_eeprom(ARRAY + 2);
}

When I simulate it whith MPLabSim, data is always 0...
Ttelmah
Guest







PostPosted: Fri Aug 25, 2006 6:57 am     Reply with quote

I suspect the problem is in the way the simulator integrates with the compiler. There is a 'bug' in some version combinations, which results in breakpoints, not actually stopping where you think they are. The code should work, but there is a 'caveat', that it'll return '1'. Each _word_ is two addresses higher than the last, so 'array+2', accesses the second value.

Best wishes
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Aug 25, 2006 8:18 am     Reply with quote

I tried the given example program in PCWH v3.249, MPLAB v7.41 for a PIC18F4550 and it worked as expected.

Which compiler, MPLAB version and processor type are you using?
Akutabi



Joined: 18 Aug 2006
Posts: 6

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 2:56 am     Reply with quote

I used PCM 3.49d, MPLAB 7.41 and 16F688.
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