View previous topic :: View next topic |
Author |
Message |
Akutabi
Joined: 18 Aug 2006 Posts: 6
|
DA instruction in ASM with CCS ? |
Posted: Thu Aug 24, 2006 8:55 am |
|
|
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.
Thank you, |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
Akutabi
Joined: 18 Aug 2006 Posts: 6
|
|
Posted: Fri Aug 25, 2006 2:39 am |
|
|
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
|
|
Posted: Fri Aug 25, 2006 3:13 am |
|
|
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
|
|
Posted: Fri Aug 25, 2006 6:57 am |
|
|
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
|
|
Posted: Fri Aug 25, 2006 8:18 am |
|
|
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
|
|
Posted: Wed Aug 30, 2006 2:56 am |
|
|
I used PCM 3.49d, MPLAB 7.41 and 16F688. |
|
|
|