|
|
View previous topic :: View next topic |
Author |
Message |
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
problem with constant array |
Posted: Sun Oct 29, 2006 11:15 am |
|
|
I cant understand whats happening.
I define a constant array, then want to pick up the value.
it gets it wrong.
can anyone see whats wrong ?
I get the index from a ram array, which works fine, but when I try to get the rom value, it disappears into a call 055, which by single step debugging goes to an interrupt service routine.
it does return though.
fred has the value of 0x07, so it should return 0x0B, but doesnt, it returns 0x15
CCS PCM C Compiler, Version 3.249, 29656 29-Oct-06 16:43
//char const Shutter_Speeds[] = {0x00,0x02,0x03,0x04,0x05,0x06, 0x08, 0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15 } ;
...................
.................... fred=_Shutter_Table[Shutter_counter];
0C8B: MOVLW 71
0C8C: ADDWF 7C,W
0C8D: MOVWF 04
0C8E: MOVF 00,W
0C8F: MOVWF 41 // this gives fred a value of 0x07, which is correct
.................... debug_Nops;
0C90: NOP
0C91: NOP
0C92: NOP
0C93: NOP
0C94: NOP
.................... Shutter_Value=Shutter_Speeds[fred];
0C95: MOVF 41,W
0C96: BCF 0A.3
0C97: BCF 03.5
0C98: CALL 055
0C99: BSF 0A.3
0C9A: MOVWF 78
0C9B: BSF 03.5
0C9C: MOVWF 40
....................
.................. |
|
|
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
|
Posted: Sun Oct 29, 2006 11:41 am |
|
|
I think you want the const before the char:
const char Shutter_Speeds[] = . . .
This may not make any difference, but this is the way it works for me. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 29, 2006 12:36 pm |
|
|
When it calls 0055, it should be calling a ROM array access routine.
This will calculate an address in the array and then jump to a RETLW
instruction which returns the correct array element.
1. Post a very short but complete program that shows the problem. Show
the #include statement, #fuses statement, and any #use statements.
2. Post the debugger that you're using.
3. If you're using MPLAB IDE, post the version. |
|
|
|
|
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
|