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

Pointers to high banks?

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







Pointers to high banks?
PostPosted: Mon Apr 26, 2004 11:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 26, 2004 11:58 pm     Reply with quote

Add this line to your code:

#device *=16

It tells the compiler to use 16 bit pointers (for 14 bit parts).
Jeprox
Guest







PostPosted: Wed Apr 28, 2004 9:54 pm     Reply with quote

In addition to Haplo's answer initialise the pointers inside main() as well.
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