PORT Registers initialization to safe state

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PORT Registers initialization to safe state

1,407 Views
girichavana
Contributor II

Hello,

     I am working on the MCU MC9S08SG16 (28PIN).

     I need to initialize the IO ports to a safe state.

     As per the data sheet, it is safe to initialize the UN connected pins as OUTPUT.

     But in my case all pins are connected only.

 

     Suppose for safe state analysys, if a Input device is connected to a Port pin which is configured as OUTPUT,

     Then is there any damage to the io pin ?

 

     Also suggest me the better ports configuration for the safety critical applications.

 

Thanks

Giri

Labels (1)
6 Replies

795 Views
Lundin
Senior Contributor IV

By tradition, all Freescale microcontrollers have all I/O pins set as unprotected inputs out of reset. I'm guessing the reason was power consumption, at some point in history. But whenever you speak to a Freescale technician, the always make the recommendation that set unused pins as outputs to make them safe. So there are two contradicting Freescale design advices: the shipped MCU comes with one default recommendation, the humans tell you another thing.

First of all, no pin should be left unconnected! Fix that first.

If the unused pins are left as inputs, there is a potential for circuit damage through transients and ESD. Every pin is internally protected with diodes, and some pins may also have pull resistors enabled out of reset. In my experience from using HCS08 and HCS12 during the past 10 years, these diodes are quite sufficient to handle various transients and EMC glitches, but they may not be able to handle ESD.

For safety-critical applications, I have used some simple, external protection on all I/O pins that are set as inputs out of reset, such as a pull-down resistor of 10k on unused pins. Some ports may have internal pull resistors enabled out of reset and then the external resistor isn't needed. Over the years, I have gradually started to replace these with the pin tied directly to ground, without any problems, so the external pull resistor might be a bit overkill. A lot will of course depend on the ground layout of the PCB.

All unused pins should be set as outputs through its DDR register. Set all unused port data register to zero (though they should already be zero out of reset). When the pin is set as output, it should be safe from most external signals, unless they are of an extreme nature. But note that since you set pins as outputs through software after MCU reset, any external voltages applied to the pin when the MCU program is not up and running, will be dangerous. You need external protection against that.

Overall, the main reason to pick Freescale MCUs is because they excellent at handling EMC and transients. The MCUs perform very well even in extreme environments. Personally, this is the one single reason I am using them.

795 Views
eduardo_viramon
NXP Employee
NXP Employee

Giri, the best configuration for any set of pins both for safety and for power consumption issues is to have the pins default to a known state (that is, either o or 1). For floating pins the default configuration we recommend is output zero. For used pins it entirely depends on what the configuration is and what is connected to it.

Outputs should be configured as an output and to the "safe value". For example, if their driving a relay, then turn the relay off, etc. If there is no concern as to what value is safe, then use zero.

Inputs will depend entirely on what is connected to the pin. What you should make sure is that whatever is driving that pin is always a zero or a one when it is not being used. There is an additional option you have with inputs with value unknown which is to enable the pull-up to that pin, to make sure the pin is set to a fixed value while not in use.

795 Views
girichavana
Contributor II

Hi,

Thanks for the clarification. It will be more helpful for me if you clrify the below

"If a Input device is connected to a Port pin which is configured as OUTPUT, 

     Then is there any damage to the io pin ?  "

0 Kudos

795 Views
eduardo_viramon
NXP Employee
NXP Employee

I don't fully understand the question. If you mean that the MCU pin is configured as an output and the device it is connected to drives less than the maximum amount of current for that pin, then there should be no problem.

0 Kudos

795 Views
girichavana
Contributor II

Hi,

Let us suppose, Presently I am driving a relay with my IO pin. So, I configured the direction of the IO line as output. By mistake, if a digital sensor (Input device) is connected for the same pin which was configured as Output, then is there any problem to the IO Line ?

Regards

Giri Chavana

0 Kudos

795 Views
rocco
Senior Contributor II

Hi Giri,

girichavana wrote:

. . . then is there any problem to the IO Line ?

Yes.

Anytime you have more than one output driving an I/O line at the same time, you have what is called "contention" on the line. I can be harmless (but still a serious mistake), if both devices drive to the same level. But if they try to drive to opposite levels, then you will get over-current at the least, and possible destruction of either/both devices.