I'm struggling to understand how CCS handles pointers...
I want to set up a pointer to some device registers in Bank3. When I look at the generated code, it seems to use only 8-bit pointers, ignoring the higher bits of the pointer and not setting the bank select bits in the STATUS register.
What am I doing wrong? This is an eg...
Code:
#byte a_reg = 0x1a0
unsigned char buffer[8];
function() {
int i = 0;
unsigned char * Ptr = &a_reg;
while(i<8) {
buffer[i++] = *Ptr++;
}
}
When I look at similar code, it only use 8 bits for the pointer, clearly accessing bank 0, not bank 3.
Clues? Help?
Thanks.
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
Posted: Mon Apr 26, 2004 11:58 pm
Add this line to your code:
#device *=16
It tells the compiler to use 16 bit pointers (for 14 bit parts).
Jeprox Guest
Posted: Wed Apr 28, 2004 9:54 pm
In addition to Haplo's answer initialise the pointers inside main() as well.
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