EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Avoiding a short circuit at boot up

Started by Unknown February 11, 2008

    I'm very new to working with microcontrollers, I only started using 
them properly within the last week.

    I'm using the PIC16F684 in conjunction with MPLAB and PIC C.

    One of my pins on the PIC chip is connected to the output from an 
encoder. The output from the encoder will always be either 5 V or 0 V, it 
will never be high impedence.

    When power is applied to my circuit and the microcontroller boots up, I 
need to make sure that the pins are all high impedence, because if any of 
them are high or low then I'll have a short circuit leading to the encoder.

    Does anyone know how to ensure that all the pins on the 16F684 will be 
high impedence initially?

    My pin layout for the PIC16F684 is:

C0 thru C5: Output to LED's

A0: Output to LED

A1 thru A3: Input from Encoder

A4: Output to the clock input of a shift register

A5: Output to a Piezo speaker


    Basically I want to use all 12 pins, I don't want them to be set to 
anything like A/D convertors or clock inputs. Does anyone know what 
__CONFIG parameters I need to achieve this?

    Basically I want either:
1) All pins are high impedence at the start, and then my code in main sets 
them as per my specifications above.
2) All pins are set the way I want them when the chip boots up by using 
__CONFIG parameters (I don't even know if this is possible).

    Also, does anyone know how long it takes for the PIC16F684 to boot up 
and actually start executing instructions? I've been told that it executes 
its first instruction about 20 milliseconds after power is applied; does 
this sound about right? Also does anyone know how long it takes for the pin 
voltage to change once the machine instruction has been executed?

-- 
Tom�s � h�ilidhe
Tom�s � h�ilidhe wrote:
> > I'm very new to working with microcontrollers, I only started using > them properly within the last week. > > I'm using the PIC16F684 in conjunction with MPLAB and PIC C. > > One of my pins on the PIC chip is connected to the output from an > encoder. The output from the encoder will always be either 5 V or 0 V, it > will never be high impedence. > > When power is applied to my circuit and the microcontroller boots up, I > need to make sure that the pins are all high impedence, because if any of > them are high or low then I'll have a short circuit leading to the encoder. > > Does anyone know how to ensure that all the pins on the 16F684 will be > high impedence initially?
After reset, all I/O pins are set to inputs. The datasheet shows that after a reset, the TRIS bits are set to '1'. So, there won't be a conflict.
Tom�s � h�ilidhe wrote:
> > I'm very new to working with microcontrollers, I only started using > them properly within the last week. > > I'm using the PIC16F684 in conjunction with MPLAB and PIC C. > > One of my pins on the PIC chip is connected to the output from an > encoder. The output from the encoder will always be either 5 V or 0 V, it > will never be high impedence. > > When power is applied to my circuit and the microcontroller boots up, I > need to make sure that the pins are all high impedence, because if any of > them are high or low then I'll have a short circuit leading to the encoder. > > Does anyone know how to ensure that all the pins on the 16F684 will be > high impedence initially? > > My pin layout for the PIC16F684 is: > > C0 thru C5: Output to LED's > > A0: Output to LED > > A1 thru A3: Input from Encoder > > A4: Output to the clock input of a shift register > > A5: Output to a Piezo speaker > > > Basically I want to use all 12 pins, I don't want them to be set to > anything like A/D convertors or clock inputs. Does anyone know what > __CONFIG parameters I need to achieve this? > > Basically I want either: > 1) All pins are high impedence at the start, and then my code in main sets > them as per my specifications above. > 2) All pins are set the way I want them when the chip boots up by using > __CONFIG parameters (I don't even know if this is possible). > > Also, does anyone know how long it takes for the PIC16F684 to boot up > and actually start executing instructions? I've been told that it executes > its first instruction about 20 milliseconds after power is applied; does > this sound about right? Also does anyone know how long it takes for the pin > voltage to change once the machine instruction has been executed? >
I don't know PICs but how about providing a resistor between encoder output and PIC? Just in case some piece of code goes wrong and it assigns that pin as output. -- Regards, Joerg http://www.analogconsultants.com/
Arlet Ottens wrote:
> Tom�s � h�ilidhe wrote: >> >> I'm very new to working with microcontrollers, I only started >> using them properly within the last week. >> >> I'm using the PIC16F684 in conjunction with MPLAB and PIC C. >> >> One of my pins on the PIC chip is connected to the output from an >> encoder. The output from the encoder will always be either 5 V or 0 V, >> it will never be high impedence. >> >> When power is applied to my circuit and the microcontroller boots >> up, I need to make sure that the pins are all high impedence, because >> if any of them are high or low then I'll have a short circuit leading >> to the encoder. >> >> Does anyone know how to ensure that all the pins on the 16F684 >> will be high impedence initially? > > After reset, all I/O pins are set to inputs. The datasheet shows that > after a reset, the TRIS bits are set to '1'. So, there won't be a conflict.
This is normal for most microcontrollers these days, at least for pins that can be either input or output. You should _always_ check the data sheet carefully, though. Data sheets never modify themselves* to your disadvantage after your design is set in stone, although this sometimes seems to be the case. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Joerg wrote:
> Tom�s � h�ilidhe wrote: >> >> I'm very new to working with microcontrollers, I only started >> using them properly within the last week. >> >> I'm using the PIC16F684 in conjunction with MPLAB and PIC C. >> >> One of my pins on the PIC chip is connected to the output from an >> encoder. The output from the encoder will always be either 5 V or 0 V, >> it will never be high impedence. >> >> When power is applied to my circuit and the microcontroller boots >> up, I need to make sure that the pins are all high impedence, because >> if any of them are high or low then I'll have a short circuit leading >> to the encoder. >> >> Does anyone know how to ensure that all the pins on the 16F684 >> will be high impedence initially? >> >> My pin layout for the PIC16F684 is: >> >> C0 thru C5: Output to LED's >> >> A0: Output to LED >> >> A1 thru A3: Input from Encoder >> >> A4: Output to the clock input of a shift register >> >> A5: Output to a Piezo speaker >> >> >> Basically I want to use all 12 pins, I don't want them to be set >> to anything like A/D convertors or clock inputs. Does anyone know what >> __CONFIG parameters I need to achieve this? >> >> Basically I want either: >> 1) All pins are high impedence at the start, and then my code in main >> sets them as per my specifications above. >> 2) All pins are set the way I want them when the chip boots up by >> using __CONFIG parameters (I don't even know if this is possible). >> >> Also, does anyone know how long it takes for the PIC16F684 to boot >> up and actually start executing instructions? I've been told that it >> executes its first instruction about 20 milliseconds after power is >> applied; does this sound about right? Also does anyone know how long >> it takes for the pin voltage to change once the machine instruction >> has been executed? >> > > I don't know PICs but how about providing a resistor between encoder > output and PIC? Just in case some piece of code goes wrong and it > assigns that pin as output. >
Yea verily. Or at least if you have the board space to do it. If you _don't_ have the board space to do it then carefully assess the amount of damage you'll do by having an output <---> output failure, and put a commensurate amount of effort into verifying your software. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
 You will learn that MicroChip is obsolete .

 Use A.R.M. , its modern , lower cost for
 the same job .
werty wrote:
> You will learn that MicroChip is obsolete . > > Use A.R.M. , its modern , lower cost for > the same job .
A 14 pin A.R.M. with RAM Flash and internal oscillator for $1.44 USD? (list for the PIC16F684) What is the part number? A PIC16F54 is under 50 cents Sometimes little jobs only need little CPUs.
Neil wrote:
> werty wrote: >> You will learn that MicroChip is obsolete . >> >> Use A.R.M. , its modern , lower cost for >> the same job . > A 14 pin A.R.M. with RAM Flash and internal oscillator for $1.44 USD? > (list for the PIC16F684) > > What is the part number? > > A PIC16F54 is under 50 cents > Sometimes little jobs only need little CPUs.
No, ARMs are not *that* cheap or small. They're getting close, though, and they may be a good alternative for the bigger PIC devices. http://www.luminarymicro.com/products/lm3s101_microcontroller.html ARM Cortex, 28 pins, internal oscillator, 2K RAM, for $2.18 (single qty @ Digi-Key)
werty wrote:
> You will learn that MicroChip is obsolete.
Microchip is a company, not a device. As a company, they supply a great number of cores, under the umbrella branding of PIC.
> > Use A.R.M. , its modern , lower cost for > the same job .
There is a whole world out there : A great many applications are chosen on the P's : Pincount, Power, Peripherals, Price. Notice the core is not even on this list! ARMs 'bottom out' at ~48 pins, so that leaves 6/8/10/14/16/18/20/24/28/32/36/40/44 pins, all as candidates for other cores - indeed the ARM cannot reach these applications at all. (Microchips PIC32 cores do not bother going below 64 pins) -jg
On Feb 14, 3:14 am, Jim Granville <no.s...@designtools.maps.co.nz>
wrote:
> werty wrote: > > You will learn that MicroChip is obsolete. > > Microchip is a company, not a device. > As a company, they supply a great number of cores, > under the umbrella branding of PIC. > > > > > Use A.R.M. , its modern , lower cost for > > the same job . > > There is a whole world out there : A great many applications > are chosen on the P's : Pincount, Power, Peripherals, Price. > > Notice the core is not even on this list! > > ARMs 'bottom out' at ~48 pins, > so that leaves 6/8/10/14/16/18/20/24/28/32/36/40/44 pins, all > as candidates for other cores - indeed the ARM cannot reach these > applications at all. > > (Microchips PIC32 cores do not bother going below 64 pins)
I suppose you missed the introduction of the Luminary Micro ARM parts a year or two ago???

The 2024 Embedded Online Conference