TRISIO on PIC12F683, I have a bit stuck midway


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Change _MCLRE_ON to _MCLRE_OFF, if you want to use GPIO.3 as input.

    Go back to TRISIO, and remove TRISL/TRISH.

    INTCON controls Interrupts, not the internal oscillator.
    So remove that line.

    And add ...

    ANSEL = 0 ; enable digital inputs

    hth,
    DT

  2. #2
    Join Date
    Oct 2010
    Posts
    7


    Did you find this post helpful? Yes | No

    Red face TRISIO on PIC12F683

    Well, I'm a little embarrassed because your suggestion for ANSEL=0 worked! I have two working inputs now. I thought I had tried this but measured the pin and decided it did not work. But it works as an input. One last worry remains. The input on Pin 7 (GPIO.0) still has 1.245 Volts. Vdd is 3.866 Volts. MCLR is pulled up externally with a 5.9K to Vdd. Pin 7 has an external 10K and a switch to GND. Pin 5 (GPIO.2) has the same circuit. Pin 5 measures 3.865V when the switch is not pressed. Both inputs go to zero volts when the switches are pressed. Something is still on at Pin 7 (GPIO.0).

    Here is the code that seems to work.

    ' PIC12F683 SOIC-8 Pin Assignments:

    ' Pin 1 Vdd +3.8V Power, Battery Voltage +2.5 - 4.5V
    ' Pin 2 GP5 Out GreenLED Driven by 2N2222, High = LED ON
    ' Pin 3, GP4 Out RedLED Drivven by 2N2222, High = LED ON
    ' Pin 4 GP3 N/C
    ' Pin 5, GP2 In Switch (S1), Low = Pressed
    ' Pin 6, GP1 N/C
    ' Pin 7, GP0 In Switch (S2), Low = Pressed
    ' Pin 8, Vss Supply Ground
    '
    ' Using INTRC Oscillator

    INCLUDE "modedefs.bas" ' Mode definitions for Serout
    DEFINE OSC 4
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _CP_OFF

    INTCON = %000001000 'Enable GPIO Change Int but enable interrupts later
    OSCCON = %01100000 ' 4mHz
    CMCON0 = 7 'Comparators off
    ANSEL = %00000000 ; enable digital inputs
    TRISIO = %00001111'GP0-GP3 as input
    OPTION_REG = %10000000 'Disable Pull ups

    '======== SET UP VARIABLES & INITIAL VALUES ====================================

    GreenLED VAR GPIO.5 ' Alias Green LED Drive, High = LED ON, Pin 2 Green
    RedLED VAR GPIO.4 ' Alias Red LED Drive, High= LED ON, Pin 3 Red
    SwitchS1 VAR GPIO.0 ' Alias Switch S2, Low = Pressed, Pin 7
    SwitchS2 VAR GPIO.2 ' Alias Switch S1, Low = Pressed, Pin 5
    'Pin 4 is set for external MCLR and has a 5.9K pull up

    N VAR BYTE ' Counting Variable, used in Auto-OFF Routine


    Low GreenLED
    Low RedLED


    StartLoop:
    Pause 10

    N=N+1

    If SwitchS1 = 0 Then
    High GreenLED
    ELSE
    Low GreenLED
    EndIf

    PAUSE 10

    If SwitchS2 = 0 Then
    High RedLED
    ELSE
    Low RedLED
    EndIf

    PAUSE 10

    GoTo StartLoop ' Repeat

    END

  3. #3
    Join Date
    Oct 2010
    Posts
    7


    Did you find this post helpful? Yes | No

    Default TRISO on PIC12F683

    I just wanted to add that the extra current 65uA that I was experiencing turned out to be from the BOR being enabled.

    Thanks for the forum's help.

Members who have read this thread : 0

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