12F675 / MCLR use


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648

    Default 12F675 / MCLR use

    Hi,

    Who could explain me that ???

    This simple program is a flip-flop with button debouncing ... simple, eh !

    ( Button1 is on the low side - LOW level if pushed )

    When using MCLR ... output ( GPIO.2) is LOW at power-up ... Ok

    When disabling MCLR ( internal reset ) ... output is HIGH at power-up ... ???
    Instead to what it should be !!!

    Did I miss something ???

    Code:
    ' Madproject
    '
    'Anti rebond pour sauter à la perche ( ??? )
    '
    ' 16F629 mode INTOSC @ 4 Mhz
    '
    ' le 03/09/2009 139 Lignes
    '******************************************************************************
    '******************************************************************************
    
    '******************************************************************************
    ' CONFIG
    '******************************************************************************
    
     @    __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BODEN_ON
     
    DEFINE OSC 4
    DEFINE OSCCAL_1K 1
    DEFINE BUTTON_PAUSE 100
    
    ADCON0		= 0
    ANSEL		= 0
    CMCON		= 7
    VRCON 		= 0
    OPTION_REG.5 = 0
    OPTION_REG.7 = 1   	'Disable Pull-Ups
    
    
    
                                                  
    Bouton1     VAR GPIO.0
    Bouton2     VAR GPIO.1
    Sortie      VAR GPIO.2
    'LedVisu     VAR GPIO.3			' Attention : Sortie PIC en C/O !!!
    LedVisu		 VAR GPIO.4
    'set         VAR GPIO.5
    
    x           VAR byte
    Delay		VAR byte
    
    GPIO 		= %00000011			'All pins LOW IF outputted - no startup bug.
    TRISIO 		= %00000011         'set GPIO.0 & GPIO.1 as inputs Others Output
    
    '******************************************************************************
    Attente: ' On attend !!!
    '******************************************************************************
    
        Delay = 0
       	BUTTON Bouton1,0,255,0,Delay,1,Action		' Poussoir à la masse enfoncé
    
    	PAUSE 10									' 10 ms entre scans
    	GOTO Attente   								' Non? : retour départ 
     
    '******************************************************************************   
    Action:	' On a enfoncé le bouton plus de 100 ms
    '******************************************************************************
    
       TOGGLE Sortie								' On inverse la sortie
       TOGGLE LedVisu
       
    '******************************************************************************   
    Attente2: ' On attend que le bouton soit relâché ...
    '******************************************************************************
    
       Delay = 0
       BUTTON Bouton1,1,255,0,Delay,1,Attente		' Le bouton est il relaché ???
       												'
       GOTO Attente2									'  NON On boucle
    
    '******************************************************************************   
       END
    Alain
    Last edited by Acetronics2; - 3rd September 2009 at 20:00.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Never trust the state of any I/O on Power-Up - regardless of what the Datasheet says.

    Always preset your I/O's within your program to what you want them to be as one of the first things you do when initialising the PIC.

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    From the datasheet...
    Figure 3-3 shows the diagram for this pin. The GP3 pin
    is configurable to function as one of the following:
    • a general purpose input
    • as Master Clear Reset
    and...
    bit 5 MCLRE: GP3/MCLR pin function select(5)
    1 = GP3/MCLR pin function is MCLR
    0 = GP3/MCLR pin function is digital I/O, MCLR internally tied to VDD
    and from your config fuses...
    _MCLRE_ON

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I think Alain is talking about GPIO.2 having an anomally when you configure GPIO.3 (MCLR) for different states. In theory it shouldn't effect that pin...

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    I think Alain is talking about GPIO.2 having an anomally when you configure GPIO.3 (MCLR) for different states. In theory it shouldn't effect that pin...
    Ahhh! I misunderstood and thought he was trying to make GPIO.3 an output although I expected he would know better. I should have known better.

    What happens if the order of the TRISIO = and GPIO = statements are reversed?

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Melanie View Post
    Never trust the state of any I/O on Power-Up - regardless of what the Datasheet says.

    Always preset your I/O's within your program to what you want them to be as one of the first things you do when initialising the PIC.
    Hi, Mel

    You do know the only one I trust in, is you, Mel ... ( Violins [ON] , Crooner [ON], Rose Petals drop [ON], Champagne [ON] ... )

    I just think you missed my two I/O Config lines ... ( Was late, eh ...)

    I must tell it ALSO affects GPIO.4 ... so, I have to try adding a little PAUSE after those CONFIG Lines, I smell a Power on little issue ... That make BUTTON read a low level when power up ...

    OR May be a " HIGH GPIO.0 " Command before the first BUTTON Command to ensure the High Level ...

    Testing a HIGH level for Button1 pressed is to also an idea ( some capacitive effects on GPIO.0 ??? ... despite it has no load but a Pullup resistor !) ...

    But, that's not something " normal " ...

    Alain
    Last edited by Acetronics2; - 4th September 2009 at 08:40.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Silicon bug ??? The end

    As I smelled ...

    Adding a little PAUSE 50 ( 40 is not enough ! ) just past the I/O config Lines solved the issue ...

    HIGH GPIO.0 didn't work ...

    Alain ( bug killer ...)
    ************************************************** ***********************
    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 " !!!
    *****************************************

Similar Threads

  1. How to MCLR by code for 16F877
    By fbestepe in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th November 2014, 00:51
  2. MCLR as PIN on 12F675
    By rgregor in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th October 2009, 09:46
  3. 12F675 MCLR directive MPASM
    By OLDSCHOOL in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th May 2008, 01:29
  4. 12F675 won't reprogram or erase
    By modifyit in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 19th May 2006, 05:07
  5. I/O pin and MCLR
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 1
    Last Post: - 15th July 2004, 10:52

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