PDA

View Full Version : 18f452 portc.1



markcadcam
- 13th February 2009, 11:40
Hi All,

I need to use PORTC.1 as a digital I/O pin on a 18F452 pic. I have looked at the documentation for this microprocessor but I could not find how to configure this pin as just a digital I/O. When I run the code PORTC.1 = 1, the output remains at zero voltage. If run the code HIGH PORTC.1 it will output 5 volts. All other pins on this port work fine except for PORTC.1. I know this pin has special functionality that is causing this problem I think. Does anyone know how to configure this pin for a digital I/O?

Thanks,
Mark

Acetronics2
- 13th February 2009, 12:48
Hi, Mark

So, everything fine !!!




PORTC is an 8-bit wide, bi-directional port. The corresponding
Data Direction register is TRISC. Setting a
TRISC bit (= 1) will make the corresponding PORTC
pin an input (i.e., put the corresponding output driver in
a Hi-Impedance mode). Clearing a TRISC bit (= 0) will
make the corresponding PORTC pin an output (i.e., put
the contents of the output latch on the selected pin).



IF you had Read This F... Datasheet ...

Alain

markcadcam
- 13th February 2009, 12:54
Hi Alain,

I've tried TRISC = %00000000 setting all to ouputs before. I get the same result.

Mark

nemesis
- 13th February 2009, 13:11
You need to set the adcon register. Search for it in the datasheet. If I get time later I'll download it and look.
Nemesis

Acetronics2
- 13th February 2009, 13:20
Hi Mark

What's the load on PortC.1 ??? ... mosfet Gate ???

Alain

PS: no other "disturbing" function on this PIN ... except



When the Timer1 oscillator is enabled (T1OSCEN is
set), the RC1/T1OSI and RC0/T1OSO/T1CKI pins
become inputs. That is, the TRISC<1:0> value is
ignored, and the pins are read as ‘0’.


What about T1OSCEN ??.

Pic2008
- 13th February 2009, 13:20
Pls post your code here so that we can see what's wrong.

markcadcam
- 13th February 2009, 13:25
When running the code below I do NOT get 5 volts out of PORTC.1. I can change the code to use any other pin on PORTC and I DO get 5 volts out. The problem is with just PORTC.1

Mark

Input PORTC.2
output PORTC.1
INPUT PORTC.0
output PORTD.0
OUTPUT PORTC.3
OUTPUT PORTD.1

ADCON1 = 7 'set I/O pins to digital on PORT.A
define OSC 20
define LOADER_USED 1 ' bootloader
Include "modedefs.bas"
T1CON = 3 'Turns on Timer1
PORTC.1 = 1

nemesis
- 13th February 2009, 13:49
turn off ad all together. adcon0 = 0
see if that helps.
Nemesis

Acetronics2
- 13th February 2009, 13:56
Hi,

THE Good Ol' Method ... always lead to success !!!





'@ __CONFIG _CONFIG1L, _WDT_OFF_1L & _WDTPS_128_1L

@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _BORV_27_2L & _PWRT_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H

'@ __CONFIG _CONFIG3L, _WDT_OFF_3L & _WDTPS_128_3L

@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
@ __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L

'@ __CONFIG _CONFIG4H, _WDT_ON_4H & _WDTPS_128_4H

@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H

Input PORTC.2
output PORTC.1
INPUT PORTC.0
output PORTD.0
OUTPUT PORTC.3
OUTPUT PORTD.1

ADCON1 = 7 'set I/O pins to digital on PORT.A
define OSC 8 ' to suit my Easy Pic5
'define LOADER_USED 1 ' bootloader ' "
Include "modedefs.bas"
T1CON = 3 'Turns on Timer1

More:
PORTC.1 = 1
HIGH PORTC.1

PAUSE 500

PORTC.1 = 0
LOW PORTC.1

PAUSE 500

GOTO More
END



It's in, the CONFIG !!! ...

Alain

markcadcam
- 13th February 2009, 14:08
Thanks Alain, I'll try it out tonight.

Mark

adamxis
- 14th March 2009, 04:47
Hi,
i want to configure all portB as output digital,but seems problem coz the voltage out from the pin is juz below 2.4V...not enough for my application,4V
i noe that if the setting is right, i/o digital, the pin will out 3.3V at least

I'm using dspic30F3013...
i have try set the portB to output and don want any analogs..
here the code

SET_TRIS_B( 0x00000000 );
SETUP_ADC(0x00000000);

Owh...i'm using PIC-C compiler...

don no where the mistake...
please help :confused: