PDA

View Full Version : 18F2520 - problem configuring fuse for port B as digital port.



hwhisperer
- 10th October 2010, 07:35
Hi to all...

sorry for my english, I'm italian and now I work and live in Bulgaria.

this is the first time I post someting but... I used many times the informations that come from your forum... :-)

Now, I have a problem migrating some my projects born for 16F876 to 18F2520.
I use PBP 2.46 and I need to configure the fuse for have pins 0-4 in port B as digital input at reset.

I used the configuration scheme that Melanie suggests in her post n.2358:

@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
' MCLR is OFF (internal)
' PortB 4:0 is digital on Reset
' CCP2 is Multiplexed with PortC.1

...butchered in this way:

@ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
' MCLR is ON
' PortB 4:0 is digital on Reset
' CCP2 is Multiplexed with PortC.1

...becouse I want use MCLR in external way.

The problem is that it dont works and pins 0-4 in port B still work as analogic input...

There is someting wrong?
Maybe I forget someting...

Thankyou in advance.

Stefano

Archangel
- 11th October 2010, 03:32
You need to get into the data sheet for your PIC18F2520. and read how to set the registers. They control whether the ports are analog or digital.
You have ADCON0, ADCON1,ADCON2, ADRESH, ADRESL, CCP REGISTER . . .
THIS IS FROM THE DATA SHEET . . .


Note: On a Power-on Reset, RB4:RB0 are
configured as analog inputs by default and
read as ‘0’; RB7:RB5 are configured as
digital inputs.
By programming the configuration bit,
PBADEN, RB4:RB0 will alternatively be
configured as digital inputs on POR.
I "THINK" this means PBADEN should be on.
hth
JS

hwhisperer
- 11th October 2010, 11:41
Yes, thanks... Now it works... I had to configure properly the bits in ADCON1.
My mistake was to think that, using the CONFIG, it was automatically done...

stefano