Avoiding a short circuit at boot up

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
Reply to
Tomás Ó hÉilidhe
Loading thread data ...

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/
Reply to
Joerg

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.

Reply to
Arlet Ottens

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
Reply to
Tim Wescott

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
Reply to
Tim Wescott

You will learn that MicroChip is obsolete .

Use A.R.M. , its modern , lower cost for the same job .

Reply to
werty

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.

Reply to
Neil

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.

formatting link

ARM Cortex, 28 pins, internal oscillator, 2K RAM, for $2.18 (single qty @ Digi-Key)

Reply to
Arlet Ottens

Microchip is a company, not a device. As a company, they supply a great number of cores, under the umbrella branding of PIC.

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

Reply to
Jim Granville

I suppose you missed the introduction of the Luminary Micro ARM parts a year or two ago???

Reply to
rickman

Apparently you have no meaningful purpose for this hardware .

You post ........ $1.44 .... Whats the total cost in h/w and your time ?!!.

I always write about important and productive uses for electronics .

The is no faster nor easier way to inmplement a powerful mcu , that with A.R.M.

The slowest and most frustrating is MicroChip mcu's , next comes Intel 8051

with its "simulated" control of external memory !

The STR710FZ2 has no bottlenecks nor extra chips needed .

no one wants to EVB , so ill use an avail' LPC2292 ,144 pins , but way less internal SRAM ,

external 1/2 MB SRAM and 2MB Flash ...

As soon as i stop travelling so much , ill give away a free Forth O.S. for the ARM .

Reply to
werty

Don't hold your breath, people. werty is best known for his trolling, i.a. on comp.lang.forth.

Groetjes Albert

--

--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Reply to
Albert van der Horst

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.