• AVR Freaks

Hot!PIC12F683 - Strage GPIO Behaviour

Author
arindam_das_0001
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2020/03/28 13:20:25
  • Location: 0
  • Status: offline
2020/08/08 10:57:05 (permalink)
0

PIC12F683 - Strage GPIO Behaviour

I wrote a simple program to make a dice.
I noticed that when I turn on GP1 only, it works as expected. But if I turn on another port GP1 immediately goes low. This does not happen with any other port. In order to maintain high state on GP1 I had to turn GP1 again after turning on any other port.
Can you help me understand why this is happening.
#1

5 Replies Related Threads

    Joel_C
    Starting Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/12/28 14:13:53
    • Location: CT, USA
    • Status: online
    Re: PIC12F683 - Strage GPIO Behaviour 2020/08/10 12:56:48 (permalink)
    +2 (2)
    Sounds to me that you have a R-M-W (Read Modify Write) problem. A common problem with older PIC chips.
    Do a search and you should find many threads with suggestions for solving this problem. Most people would use a newer chip with LAT (Latch) capability.
     
    Joel
     
    #2
    ric
    Super Member
    • Total Posts : 28299
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC12F683 - Strage GPIO Behaviour 2020/08/10 13:39:18 (permalink)
    +1 (1)
    +1 you are experiencing RMW problems.
    You have correctly switched your analog pins to digital, so if you also insert a NOP() macro in between each of the instructions setting an output pin, that will probably fix your problem.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    nice
    Super Member
    • Total Posts : 1094
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    Re: PIC12F683 - Strage GPIO Behaviour 2020/08/10 22:15:44 (permalink)
    0
     
    Old PIC... Try
    CMCON0 = 0b00000111;

     
    With CM<2:0> = 000 GP0 and GP1 are analog pins which read back as '0'. 
    post edited by nice - 2020/08/10 22:30:54
    #4
    ric
    Super Member
    • Total Posts : 28299
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC12F683 - Strage GPIO Behaviour 2020/08/10 23:07:31 (permalink)
    +1 (1)
    Good point.
    There's really no excuse for not initialising the GPIO port properly, when the correct sequence is listed explicitly in the datasheet under "EXAMPLE 4-1: INITIALIZING GPIO".

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    upand_at_them
    Super Member
    • Total Posts : 634
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: PIC12F683 - Strage GPIO Behaviour 2020/08/11 05:13:37 (permalink)
    0
    ANSEL = 0b00000000;
    ADCON0 = 0b00000000;
    CMCON0 = 0b00000111;
    CMCON1 = 0b00000000;

    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5