I/O Pin status during startup


+ Reply to Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Jul 2024
    Posts
    27

    Default I/O Pin status during startup

    Hi guys,

    quick question...

    Is there a way (somewhere on the datasheet for example) to know what are the I/O pins state during power up?
    I've noticed that some I/O pins (on my 18F2580 MCU) start high even placing "clear" and "PORTA=000000, PORTB=000000, PORTC=000000) at the start of the code (when i say start, i mean after all the configuration lines).
    I currently have the "INCLUDE "ALLDIGITAL.pbp"" before the actual code start.

    How can I force all the I/Os to be low until the code tells them to go high?

    Thanks
    Last edited by PaulMaker; - 16th January 2025 at 13:27.

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


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    no defined I/Os state before you set it ...

    the one and only way is an external pull up or down resistor, as I/Os are placed in an INPUT state ( High impedance ) @ power up ...

    moreover, you have to manually set input state before some PBP Commands ( pulsin, RC Time, Toggle ... ) to be sure of what you get.

    Alain
    Last edited by Acetronics2; - 16th January 2025 at 14:24.
    ************************************************** ***********************
    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
    Jul 2024
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Hi Acetronics2,
    thanks for your reply.

    To be accurate, during power on, these I/Os turn on and off (and then stay off) very quickly (like a flash). The idea is to stop that high-low behavior.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Quote Originally Posted by PaulMaker View Post
    Hi
    To be accurate, during power on, these I/Os turn on and off (and then stay off) very quickly (like a flash). The idea is to stop that high-low behavior.
    Simple answer- you cannot do that.

    You should design your project with active low outputs to account for the High-Z input state at power on. Almost every microcontroller, I know, behaves similarly unless there is special hardware built in to retain a certain state at power on. Till such time as your program code runs, the microcontroller IO pins are kept in a High-Z state to prevent unintentional damage to itself.

  5. #5
    Join Date
    Jul 2024
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Greetings,

    thank you Jerson for your reply.

    Regarding "design your project with active low outputs to account for the High-Z input state at power on", what do you mean exactly?
    If, for example, I only have LEDs on these I/Os, what can I do?





  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,573


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    if you have leds that illuminate on power up before the pins have been set as outputs then you are doing something very odd
    or you have broken something

    schematic and code ?
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,590


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Yeah, this sounds very strange.

    As others have said, after power on and reset (POR) all the pins come up as inputs so they should not go either high or low for any duration. Leakage current into the pin is MUCH less than a uA (200nA max) so basically "any" sort of resistance (ie several mega Ohms) to either Vdd or Vss will pull the pin to that.

    And it doesn't really matter what you do with the PORT or LAT registers until you also clears the TRIS bits in questions. Ie, at power up the pins are inputs (high impedence), then you "preset" their default state(s) by writing to PORT or LAT and finally you clear the corresponding TRIS bits to enable the output drivers.

    The 18F2580 have pull-ups on PORTB (and PORTB only it seems). They are disabled on POR so they should not be able to pull the pin high. The current sourced thru the pull-up resistor is between 50 and 400uA so even WITH them enabled I don't think you'd see a LED light up.

    More details please...

  8. #8
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Quote Originally Posted by PaulMaker View Post
    Greetings,

    thank you Jerson for your reply.

    Regarding "design your project with active low outputs to account for the High-Z input state at power on", what do you mean exactly?
    If, for example, I only have LEDs on these I/Os, what can I do?




    Many a times, I have used an I/O pin to drive a relay through a transistor. So, assuming I need an active high output to turn on the relay, I have observed (across microcontroller families) that the relay flicks on for the fraction of a second till the program code takes control and the pin get set to the off - state of the relay (0). So, the ideal way to resolve such a situation is to ensure that the relay turns on only when the I/O pin is made to output a LOW.

    In case of driving an LED from an IO pin, my thinking is biased with the TTL logic output specificiation where the sinking current limit is larger than the sourcing current limit. So, I usually tend to use LEDS with an active low output configuration. The IO port has to be low for the LED to turn on. This spec thing is no longer true with the current generation of microcontrollers except the 8051 family dies from old.

    So, as a best practice, I tend to use active low outputs for any device that needs to be turned on.

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


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    I Never saw something like that ....

    but, if we consider LEDs as current generators when illuminated ( Yes, the built in input clamp diodes ... )

    the question comes ... is the pic in a true OFF state @ "powerup" ???

    THE ONE and ONLY thing to have here is ...

    SHOW US the full Pic program ( with config ! ) and the Circuit real scheme.

    already asked for @ #6 !!!

    Alain
    Last edited by Acetronics2; - 18th January 2025 at 08:35.
    ************************************************** ***********************
    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
    Jul 2024
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Greetings all,

    thank you all for your inputs.

    Here is the code:

    Code:
    '****************************************************************'*  Name    : Led Controller.PBP                                *
    '*  Author  : Paul Maker                                        *
    '*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 19/12/2024                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : 18F2580                                           *
    '*          :                                                   *
    '****************************************************************
    '
    '
    '
    ;----[18F2580 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "18F2580"
      #DEFINE MCU_FOUND 1
    #CONFIG
      CONFIG  OSC = IRCIO67      ; Internal oscillator block, port function on RA6 and RA7
      CONFIG  FCMEN = OFF        ; Fail-Safe Clock Monitor disabled
      CONFIG  IESO = OFF         ; Oscillator Switchover mode disabled
      CONFIG  PWRT = OFF         ; PWRT disabled
      CONFIG  BOREN = OFF        ; Brown-out Reset disabled in hardware and software
      CONFIG  BORV = 3           ; VBOR set to 2.1V
      CONFIG  WDT = OFF          ; WDT disabled (control is placed on the SWDTEN bit)
      CONFIG  WDTPS = 512        ; 1:512
      CONFIG  PBADEN = OFF       ; PORTB<4:0> pins are configured as digital I/O on Reset
      CONFIG  LPT1OSC = OFF      ; Timer1 configured for higher power operation
      CONFIG  MCLRE = OFF        ; RE3 input pin enabled; MCLR disabled
      CONFIG  STVREN = ON        ; Stack full/underflow will cause Reset
      CONFIG  LVP = OFF          ; Single-Supply ICSP disabled
      CONFIG  BBSIZ = 1024       ; 1K words (2K bytes) boot block
      CONFIG  XINST = OFF        ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
      CONFIG  DEBUG = OFF        ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
      CONFIG  CP0 = OFF          ; Block 0 (000800-001FFFh) not code-protected
      CONFIG  CP1 = OFF          ; Block 1 (002000-003FFFh) not code-protected
      CONFIG  CP2 = OFF          ; Block 2 (004000-005FFFh) not code-protected
      CONFIG  CP3 = OFF          ; Block 3 (006000-007FFFh) not code-protected
      CONFIG  CPB = OFF          ; Boot block (000000-0007FFh) not code-protected
      CONFIG  CPD = OFF          ; Data EEPROM not code-protected
      CONFIG  WRT0 = OFF         ; Block 0 (000800-001FFFh) not write-protected
      CONFIG  WRT1 = OFF         ; Block 1 (002000-003FFFh) not write-protected
      CONFIG  WRT2 = OFF         ; Block 2 (004000-005FFFh) not write-protected
      CONFIG  WRT3 = OFF         ; Block 3 (006000-007FFFh) not write-protected
      CONFIG  WRTC = OFF         ; Configuration registers (300000-3000FFh) not write-protected
      CONFIG  WRTB = OFF         ; Boot block (000000-0007FFh) not write-protected
      CONFIG  WRTD = OFF         ; Data EEPROM not write-protected
      CONFIG  EBTR0 = OFF        ; Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR1 = OFF        ; Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR2 = OFF        ; Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR3 = OFF        ; Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTRB = OFF        ; Boot block (000000-0007FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    '*****************************************************************************
    
    
    OSCCON =%01110000
    OSCTUNE=%11000000
    
    
    DEFINE OSC 8
    
    
    '*****************************************************************************
    
    
    INCLUDE "ALLDIGITAL.pbp"
    DEFINE SHOWDIGITAL 1
    
    
    '*****************************************************************************
    
    
    INCLUDE "modedefs.bas" 
    'DEFINE DEBUGIN_REG PORTB  
    'DEFINE DEBUGIN_BIT 5
    'DEFINE DEBUGIN_BAUD 1200
    'DEFINE DEBUGIN_MODE 0
    
    
    '*****************************************************************************
    
    
    TRISA = %00000000				
    TRISB = %00100000
    TRISC = %00000000
    
    
    '*****************************************************************************
    
    
    'PORTS & PINS 
    
    
    LED1			var		PORTC.1 'IC5
    LED2 			var		PORTC.2 'IC5
    LED3			var		PORTC.0 'IC5
    LED4			var		PORTA.6 'IC5	
    
    
    LED5			var		PORTB.4 'IC5
    LED6			var		PORTA.7 'IC5
    
    
    LED7 			var 	PORTB.0 'IC5
    LED8 			var		PORTB.1 'IC5
    LED9 			var		PORTB.2 'IC5
    LED10 			var		PORTB.3 'IC5
    
    
    LED11			var		PORTC.3 'IC5
    LED12			var		PORTC.4 'IC5
    LED13			var		PORTC.5 'IC5
    LED14			var		PORTC.6 'IC5
    LED15			var		PORTC.7 'IC5
    
    
    LED16			var		PORTA.5 'IC5
    LED17			var		PORTA.4 'IC5
    LED18			var		PORTA.3 'IC5
    LED19			var		PORTA.2 'IC5
    LED20			var		PORTA.1 'IC5
    LED21			var		PORTA.0 'IC5
    LED22			var		PORTB.7 'IC5
    LED23			var		PORTB.6 'IC5
    
    
    IC_RX			var		PORTB.5	'IC5 INPUT
    
    
    
    
    CT					VAR		BYTE
    CT					VAR		BYTE
    PA1   				VAR 	WORD
    PA2   				VAR 	WORD
    PA3   				VAR 	WORD
    PA4   				VAR 	WORD
    
    
    '*****************************************************************************
    INIT:
    
    
    clear
    
    
    pause 100
    
    
    PORTA=%00000000
    PORTB=%00000000
    PORTC=%00000000
    
    
    TRISB.5=1
    
    
    PA1=300
    PA2=600
    PA3=900
    PA4=1500
    
    
    CT=0
    CT2=0
    
    
    pause 1000
    
    
    '-----------------------------------------------------------------
    START:
    
    
    pause 400
    
    
    high LED3
    high LED4
    
    
    pause 1600 
    
    
    high LED10
    high LED15
    
    
    pause PA4 
    
    
    high LED1	
    high LED2	
    high LED6
    HIGH LED16
    
    
    PAUSE 600  
    
    
    PAUSE PA4	
    
    
    GOTO ANIM
    
    
    '-----------------------------------------------------------------
    ANIM:
    
    
    high LED9
    high LED14
    
    
    PAUSE PA3 
    
    
    high LED8
    high LED13
    
    
    PAUSE PA3 
    
    
    LOW LED13
    
    
    PAUSE PA3 
    
    
    HIGH LED7
    
    
    PAUSE PA3 
    
    
    LOW LED7
    HIGH LED13
    
    
    PAUSE PA3 
    PAUSE PA3 
    PAUSE PA3 
    
    
    LOW LED8
    
    
    PAUSE PA3
    
    
    LOW LED13
    
    
    PAUSE PA3 
    PAUSE PA3 
    PAUSE PA3 
    
    
    HIGH LED8
    HIGH LED13
    
    
    Goto ANIM
    Regarding the schematic, I don't have one at the moment but basically it's just the MCU connected to 5V (with 1uF capacitor between VDD and GND pins) and several LEDs connected to each pin (one LED on each pin) in series with a resistor.

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,573


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    are the leds connected to gnd or vdd ?
    are the leds powered by the same supply?
    what size is the led series resistor ?


    and what does actually happen compared what you expect to happen

    note a schematic can be a picture of a simple hand drawn pencil/paper sketch , or a doodle from paint brush
    it does not need to be fancy just readable and complete
    Warning I'm not a teacher

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,590


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    So, looking at your code....effectively it boils down to
    Code:
    TRISA = %00000000	    ' This enables 23 of 24 output drivers, pins goes to whatever state PORT/LAT says			
    TRISB = %00100000
    TRISC = %00000000
    
    clear
    
    pause 100                 ' Twiddle thumbs for 100ms
    
    PORTA=%00000000     ' And THEN the pins are set to 0
    PORTB=%00000000
    PORTC=%00000000
    [/code]

    You need to do it the other way around.

  13. #13
    Join Date
    Jul 2024
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Hi Richard, thanks for the help.

    Regarding the drawing...will try to get it and post here.
    In the meantime here are the answers:

    are the leds connected to gnd or vdd ?
    The LEDs are connected to ground


    are the leds powered by the same supply?
    Yes, same power supply as the MCU

    what size is the led series resistor ?
    It's 500ohms for a SMD LED

    and what does actually happen compared what you expect to happen
    The same moment that i turn the power on, the LEDs turn on and then off very fast.
    After some seconds (when the code kicks in) the LED animation starts.

    I expect the LEDs not flash when turning the power on and only turn on when the code kicks in.

  14. #14
    Join Date
    May 2013
    Location
    australia
    Posts
    2,573


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    before you go to too much trouble try what henrik suggests

    clear all output ports before setting the tris registers and lose that delay in between
    Warning I'm not a teacher

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,633


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    did you simply try to add :

    Code:
    INIT:
    
    
    PORTA=%00000000
    PORTB=%00000000
    PORTC=%00000000
    
    
    
    
    clear
    
    
    pause 100
    
    
    
    
    TRISB.5=1
    
    
    
    
    PA1=300
    PA2=600
    PA3=900
    PA4=1500
    in the config section ...
    ************************************************** ***********************
    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 " !!!
    *****************************************

  16. #16
    Join Date
    Aug 2011
    Posts
    450


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    did you simply try to add ...
    The important part is to set the PORT (or LAT) registers BEFORE setting the TRIS registers to outputs.
    Otherwise the pins will be in output mode for a period of time but the outputs aren't specified.

  17. #17
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,633


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Hi, Tumbleweed

    the funny thing is I had added the port setting lines right before the TRIS statements for a run With MPLAB 8.92 sim ...

    Code:
    '****************************************************************'*  Name    : Led Controller.PBP                                *
    '*  Author  : Paul Maker                                        *
    '*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 19/12/2024                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : 18F2580                                           *
    '*          :                                                   *
    '****************************************************************
    '
    '
    '
    ;----[18F2580 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "18F2580"
      #DEFINE MCU_FOUND 1
    #CONFIG
      CONFIG  OSC = IRCIO67      ; Internal oscillator block, port function on RA6 and RA7
      CONFIG  FCMEN = OFF        ; Fail-Safe Clock Monitor disabled
      CONFIG  IESO = OFF         ; Oscillator Switchover mode disabled
      CONFIG  PWRT = OFF         ; PWRT disabled
      CONFIG  BOREN = OFF        ; Brown-out Reset disabled in hardware and software
      CONFIG  BORV = 3           ; VBOR set to 2.1V
      CONFIG  WDT = ON           ; WDT disabled (control is placed on the SWDTEN bit)
      CONFIG  WDTPS = 512        ; 1:512
      CONFIG  PBADEN = OFF       ; PORTB<4:0> pins are configured as digital I/O on Reset
      CONFIG  LPT1OSC = OFF      ; Timer1 configured for higher power operation
      CONFIG  MCLRE = OFF        ; RE3 input pin enabled; MCLR disabled
      CONFIG  STVREN = ON        ; Stack full/underflow will cause Reset
      CONFIG  LVP = OFF          ; Single-Supply ICSP disabled
      CONFIG  BBSIZ = 1024       ; 1K words (2K bytes) boot block
      CONFIG  XINST = OFF        ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
      CONFIG  DEBUG = OFF        ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
      CONFIG  CP0 = OFF          ; Block 0 (000800-001FFFh) not code-protected
      CONFIG  CP1 = OFF          ; Block 1 (002000-003FFFh) not code-protected
      CONFIG  CP2 = OFF          ; Block 2 (004000-005FFFh) not code-protected
      CONFIG  CP3 = OFF          ; Block 3 (006000-007FFFh) not code-protected
      CONFIG  CPB = OFF          ; Boot block (000000-0007FFh) not code-protected
      CONFIG  CPD = OFF          ; Data EEPROM not code-protected
      CONFIG  WRT0 = OFF         ; Block 0 (000800-001FFFh) not write-protected
      CONFIG  WRT1 = OFF         ; Block 1 (002000-003FFFh) not write-protected
      CONFIG  WRT2 = OFF         ; Block 2 (004000-005FFFh) not write-protected
      CONFIG  WRT3 = OFF         ; Block 3 (006000-007FFFh) not write-protected
      CONFIG  WRTC = OFF         ; Configuration registers (300000-3000FFh) not write-protected
      CONFIG  WRTB = OFF         ; Boot block (000000-0007FFh) not write-protected
      CONFIG  WRTD = OFF         ; Data EEPROM not write-protected
      CONFIG  EBTR0 = OFF        ; Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR1 = OFF        ; Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR2 = OFF        ; Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR3 = OFF        ; Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTRB = OFF        ; Boot block (000000-0007FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    
    
    
    #ENDIF
    
    
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    
    
    '*****************************************************************************
    
    
    
    
    OSCCON =110000
    OSCTUNE=000000
    
    
    
    
    DEFINE OSC 8
    
    
    
    
    '*****************************************************************************
    
    
    
    
    INCLUDE "ALLDIGITAL.pbp"
    DEFINE SHOWDIGITAL 1
    
    
    
    
    '*****************************************************************************
    
    
    
    
    INCLUDE "modedefs.bas" 
    'DEFINE DEBUGIN_REG PORTB  
    'DEFINE DEBUGIN_BIT 5
    'DEFINE DEBUGIN_BAUD 1200
    'DEFINE DEBUGIN_MODE 0
    
    
    
    
    '*****************************************************************************
    
    
    PORTA = 0
    PORTB = 0
    PORTC = 0
    TRISA = 000000                
    TRISB = 100000
    TRISC = 000000
    
    
    
    
    
    
    '*****************************************************************************
    
    
    
    
    'PORTS & PINS 
    
    
    
    
    LED1            var        PORTC.1 'IC5
    LED2             var        PORTC.2 'IC5
    LED3            var        PORTC.0 'IC5
    LED4            var        PORTA.6 'IC5    
    
    
    
    
    LED5            var        PORTB.4 'IC5
    LED6            var        PORTA.7 'IC5
    
    
    
    
    LED7             var     PORTB.0 'IC5
    LED8             var        PORTB.1 'IC5
    LED9             var        PORTB.2 'IC5
    LED10             var        PORTB.3 'IC5
    
    
    
    
    LED11            var        PORTC.3 'IC5
    LED12            var        PORTC.4 'IC5
    LED13            var        PORTC.5 'IC5
    LED14            var        PORTC.6 'IC5
    LED15            var        PORTC.7 'IC5
    
    
    
    
    LED16            var        PORTA.5 'IC5
    LED17            var        PORTA.4 'IC5
    LED18            var        PORTA.3 'IC5
    LED19            var        PORTA.2 'IC5
    LED20            var        PORTA.1 'IC5
    LED21            var        PORTA.0 'IC5
    LED22            var        PORTB.7 'IC5
    LED23            var        PORTB.6 'IC5
    
    
    
    
    IC_RX            var        PORTB.5    'IC5 INPUT
    
    
    
    
    
    
    
    
    CT                    VAR        BYTE
    CT2                    VAR        BYTE
    PA1                   VAR     WORD
    PA2                   VAR     WORD
    PA3                   VAR     WORD
    PA4                   VAR     WORD
    
    
    clear
    
    
    '*****************************************************************************
    INIT: ' setting the Variables ... )
    
    
    
    
    PA1=300
    PA2=600
    PA3=900
    PA4=1500
    
    
    pause 1000
    
    
    
    
    '-----------------------------------------------------------------
    START:
    
    
    
    
    high LED3
    high LED4
    
    
    
    
    pause 1600 
    
    
    
    
    high LED10
    high LED15
    
    
    
    
    pause PA4 
    
    
    
    
    high LED1    
    high LED2    
    high LED6
    HIGH LED16
    
    
    
    
    PAUSE 600  
    
    
    
    
    PAUSE PA4    
    
    
    
    
    '-----------------------------------------------------------------
    WHILE 1
    
    
    
    
    high LED9
    high LED14
    
    
    
    
    PAUSE PA3 
    
    
    
    
    high LED8
    high LED13
    
    
    
    
    PAUSE PA3 
    
    
    
    
    LOW LED13
    
    
    
    
    PAUSE PA3 
    
    
    
    
    HIGH LED7
    
    
    
    
    PAUSE PA3 
    
    
    
    
    LOW LED7
    HIGH LED13
    
    
    
    
    PAUSE PA3 
    PAUSE PA3 
    PAUSE PA3 
    
    
    
    
    LOW LED8
    
    
    
    
    PAUSE PA3
    
    
    
    
    LOW LED13
    
    
    
    
    PAUSE PA3 
    PAUSE PA3 
    PAUSE PA3 
    
    
    
    
    HIGH LED8
    HIGH LED13
    
    
    
    
    WEND
    With some "cleaning" ( wiped double definitions and "enlighted" the never-ending loop )

    MPLAB 8.92 ( the last one ! ) is rather useful for those simple programs debugging using checking breakpoints as it is still working fine with W11 ...
    ************************************************** ***********************
    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 " !!!
    *****************************************

  18. #18
    Join Date
    Jul 2024
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Greetings all,

    first of all, thank you so much for all your help.

    I tried moving the port settings before the Tris statement like you recommended and it worked!

    Code:
    PORTA=%00000000PORTB=%00000000
    PORTC=%00000000
    
    
    TRISA = %00000000				
    TRISB = %00100000
    TRISC = %00000000
    With this change, the LEDs don't flash anymore during startup.
    You guys nailed it!

    Thanks

  19. #19
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,633


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O Pin status during startup

    Great !

    just remember the processor does what you tell it ... and ONLY what you tell it ! ( thanks to God, PBP doesn't show too many bugs )

    so, it's always you to set ALL the parameters, registers, variables ... etc, etc ... and overall take the greatest care of the default settings !

    READ THAT F... MANUAL ( Name:  rtfm_2.gif
Views: 1182
Size:  3.3 KB )as we were used to write here. ) as a punishment, read carefully manual $ 8.1 ...

    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 " !!!
    *****************************************

Similar Threads

  1. How can I store the status of a pin?
    By Stargazer3141 in forum General
    Replies: 2
    Last Post: - 3rd December 2010, 23:59
  2. Issue with 16F88 startup
    By Plcguy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st October 2010, 16:11
  3. Startup on power up pic16f886
    By CESSKO in forum Test Area
    Replies: 0
    Last Post: - 14th April 2010, 13:26
  4. 7 second delay on startup
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd March 2006, 02:46
  5. 12F683 Startup
    By GregK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th March 2005, 01:25

Members who have read this thread : 20

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