18f452 portc.1


Closed Thread
Results 1 to 11 of 11

Thread: 18f452 portc.1

  1. #1
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    29

    Default 18f452 portc.1

    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

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Lightbulb nothing strange ...

    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Hi Alain,

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

    Mark

  4. #4
    Join Date
    Feb 2009
    Posts
    26


    Did you find this post helpful? Yes | No

    Default adcon

    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

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default

    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 ??.
    Last edited by Acetronics2; - 13th February 2009 at 14:25.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Pls post your code here so that we can see what's wrong.

  7. #7
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    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

  8. #8
    Join Date
    Feb 2009
    Posts
    26


    Did you find this post helpful? Yes | No

    Default shutdown ad for now

    turn off ad all together. adcon0 = 0
    see if that helps.
    Nemesis

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Hi,

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

    Code:
    
    '@  __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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thanks Alain, I'll try it out tonight.

    Mark

  11. #11
    adamxis's Avatar
    adamxis Guest


    Did you find this post helpful? Yes | No

    Default need help too

    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
    Last edited by adamxis; - 14th March 2009 at 06:00.

Similar Threads

  1. problem with input and output (18F452)
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th March 2008, 00:21
  2. Pic 16 F877 to 18F452...?
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st October 2007, 16:54
  3. 18F452 compile problem
    By pcbb in forum General
    Replies: 1
    Last Post: - 21st April 2007, 03:16
  4. 18F452 "Unknown Processor" errors
    By schwinn_rider in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th April 2006, 04:56
  5. Replies: 5
    Last Post: - 17th February 2006, 00:43

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts