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

18FxxJxx banked special function registers

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



Joined: 03 Dec 2009
Posts: 1

View user's profile Send private message

18FxxJxx banked special function registers
PostPosted: Fri Dec 04, 2009 12:19 am     Reply with quote

Does anyone know how to force the compiler to access a banked register? The 18FxxJxx series added a lot of features, but also added some problems. Some of the special function registers are in banked locations. Most notable is the ANCON0 and ANCON1 registers. These control the analog/digital settings on all the pins that can be analog. On reset these registers are cleared, and all pins are set to analog. To use any or all of them as digital the program must set the corresponding bit to one, using a banked instruction.

I am using the PCWH V 4.093 compiler and the setup_adc_ports() function does not work on the PIC18F26J50 part. I am porting code previously working on a PIC18F2455. My project has size constraints requiring a QFN package and a USB port. The PIC18F2450 is available in this package, but it does not have enough memory.

I attempted to set the proper pins to digital by using the following code:
#asm ASIS
movlb 0X0E
// SET ADC PORTS
movlw 0XFC // an0 an1
movwf ANCON0
movlw 0X1F // all other pins are digital
movwf ANCON1
#endasm

ANCON0 and ANCON1 are declared by
#define ANCON0 0xF48
#define ANCON1 0xF49
in the header file.

I tried using the microchip's assembler syntax
movwf ANCON0,1

This gave me a syntax error.

I also tried to a define for ANCON0, like I had seen in the .lst file for some registers.
#define ANCON0 x48

This also gave me a syntax error

I have tried a lot of other ways, but they all did nothing or gave me a syntax error.

Please help if you can.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 04, 2009 12:25 am     Reply with quote

This thread has an example of how to write directly to PIC registers
with the CCS compiler:
http://www.ccsinfo.com/forum/viewtopic.php?t=39228&highlight=byte+ansel%2A
When you do it this way, the compiler will take care of selecting the
correct bank before it writes to the address. You don't have to worry
about it.
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