Bradley Bunch
Joined: 03 Dec 2009 Posts: 1
|
18FxxJxx banked special function registers |
Posted: Fri Dec 04, 2009 12:19 am |
|
|
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. |
|