Help needed - PIC12F635- MCU does not read Ports


Closed Thread
Results 1 to 9 of 9
  1. #1

    Default Help needed - PIC12F635- MCU does not read Ports

    Hi
    This is my code:

    TRISIO=%011111
    Let GPIO=0
    w1 VAR word
    cmcon0=%111
    intcon=0
    Include "modedefs.bas"


    START:
    serin GPIO.2,N2400,["abc"],w1
    pause 10
    if w1=3 then yes
    if w1=4 then no
    if gpio.0=1 then decide
    GOTO START
    YES:
    gpio.5=1
    GOTO START
    no:
    gpio.5=0
    goto start

    decide:
    toggle gpio.5
    Low gpio.0
    pause 500
    goto start
    This code above is working fine with serial communication BUT not responding to manual control via gpio.0. I have tried this with all the available ports, making them high by giving Vdd to pins but the state to gpio.5 does not change at all.
    Could someone help me please.
    Thanks
    Damien

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    Code:
    HIGH GPIO.5
    LOW GPIO.5
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Angry

    I have tried almost everything, nothing worked untill now. BUT when I remove the serial input line from this code, it works well as expected manually. Could someone please tell me how I can use both features in this command?
    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    I have tried almost everything, nothing worked untill now. BUT when I remove the serial input line from this code, it works well as expected manually. Could someone please tell me how I can use both features in this command?
    Thanks
    Add a time out to the serial command. If a signal is not received then the code will not get stuck waiting for a serial command.
    Dave
    Always wear safety glasses while programming.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Add a time out to the serial command. If a signal is not received then the code will not get stuck waiting for a serial command.
    Did that and it works - BUT- now when I power up the circuit, my gpio.5 goes high after 1-2 seconds even though I haven't send any signal.
    Any solutions?
    Thanks

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Do you have gpio.0=1 pulled down with a 10K resistor?
    Dave
    Always wear safety glasses while programming.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Do you have gpio.0=1 pulled down with a 10K resistor?
    NO, do I have to?
    I am new in this field, I may sound silly but I have not used any resistor on any pins, they are connected directly to leds. What does this resistor do?

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I was not meaning the pins with LEDs.

    It sounds like you have gpio.0 connected to a switch of some kind.
    When the switch is pressed the pin goes HIGH.
    A pull down, resistor to ground(zero rail) will keep the pin LOW, not allowing false signals until the switch is pressed forcing the pin HIGH.
    Dave
    Always wear safety glasses while programming.

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I was not meaning the pins with LEDs.

    It sounds like you have gpio.0 connected to a switch of some kind.
    When the switch is pressed the pin goes HIGH.
    A pull down, resistor to ground(zero rail) will keep the pin LOW, not allowing false signals until the switch is pressed forcing the pin HIGH.
    Thank you very much. This problem is solved.
    Regards

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. How to read stored data from MCU EEPROM into PC?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd October 2009, 15:26
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. Write and Read from eeprom
    By savnik in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 9th June 2007, 14:56
  5. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34

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