0
\$\begingroup\$

I'm using the MC9S12DP512, Motorola's microcontroller. I was executing a service and ,at the end, I put low logic level at the pins PS4, PS5 and PS6, then after that, I configured these pins as inputs.

However, after put these pins as inputs, they present high logic level . Why it happens ?

In the datasheet says:

Port S Pull Device Enable Register (PERS)

This register configures whether a pull-up or a pull-down device is activated, if the port is used as input or as output in wired-or (open drain) mode. This bit has no effect if the port is used as push-pull output. Out of reset a pull-up device is enabled.

PERS[7:0] — Pull Device Enable Port S

1 = Either a pull-up or pull-down device is enabled.

0 = Pull-up or pull-down device is disabled.

I thought that a pull-up would be enabled, but it not happens in my code, so I checked up the motorola driver's code to verify if it is a pull-up by default. And there it is the motorola's code :

/*** PERS - Port S Pull Device Enable Register; 0x0000024C ***/
    typedef union {
      byte Byte;
      struct {
        byte PERS0       :1;                                       /* Pull Device Enable Port S Bit 0 */
        byte PERS1       :1;                                       /* Pull Device Enable Port S Bit 1 */
        byte PERS2       :1;                                       /* Pull Device Enable Port S Bit 2 */
        byte PERS3       :1;                                       /* Pull Device Enable Port S Bit 3 */
        byte PERS4       :1;                                       /* Pull Device Enable Port S Bit 4 */
        byte PERS5       :1;                                       /* Pull Device Enable Port S Bit 5 */
        byte PERS6       :1;                                       /* Pull Device Enable Port S Bit 6 */
        byte PERS7       :1;                                       /* Pull Device Enable Port S Bit 7 */
      } Bits;
      struct {
        byte grpPERS :8;
      } MergedBits;
    } PERSSTR;
    extern volatile PERSSTR _PERS @(REG_BASE + 0x0000024C);
    #define PERS _PERS.Byte
    #define PERS_PERS0 _PERS.Bits.PERS0
    #define PERS_PERS1 _PERS.Bits.PERS1
    #define PERS_PERS2 _PERS.Bits.PERS2
    #define PERS_PERS3 _PERS.Bits.PERS3
    #define PERS_PERS4 _PERS.Bits.PERS4
    #define PERS_PERS5 _PERS.Bits.PERS5
    #define PERS_PERS6 _PERS.Bits.PERS6
    #define PERS_PERS7 _PERS.Bits.PERS7
    #define PERS_PERS _PERS.MergedBits.grpPERS

I didn't understand very well this passage below:

byte PERS0       :1;                                       /* Pull Device Enable Port S Bit 0 */

The ":" is doing exactly what ? The motorola driver's code that I put here is doing a pull-up by default ?

[edited]

I want to put the pins at low logic, and after that, as input, because I don't want they stay energized at the end of the procedure.

\$\endgroup\$
1
\$\begingroup\$

To your first question, an input pin that is not driven by some other circuit can have any voltage from ground to the power supply voltage. If you only measured the voltage with a meter and did not add a resistor, say from the pin to ground, then a "high" value is perfectly reasonable.

The "code" you ask about is not executable code at all. It is defining a C struct datatype for the PERS register. The : allows you to define bit fields within a larger datatype, such as individual bits within a byte. The union allows you to access the register as a unified data value of 8 bits _PERS.Byte or as individual bits _PERS.Bits.PERS2. However, this section of code is not actually doing anything to the register; you need to write your own code to modify the value in the register as necessary.

\$\endgroup\$
  • \$\begingroup\$ I understood, thank you. But, At the end of the procedure, I desconnect the devices, and I want that the pins stay with a low logic level or high impedance at the connector, but the microcontroller dos not accept high impedance to these pins. Do you think would be a problem to configure them as out-puts with low logic level ? \$\endgroup\$ – Daniel Apr 15 at 16:25
  • \$\begingroup\$ What do you mean "disconnect the devices"...what devices are you talking about? What makes you think the MCU does not "accept high impedance"? Are you setting the pins to input mode and disabling the resistor? Why do you think there might be a problem configuring low-level outputs? You are leaving out too much information. \$\endgroup\$ – Elliot Alderson Apr 15 at 16:38
  • \$\begingroup\$ "What do you mean "disconnect the devices"...what devices are you talking about?" I said "disconnect devices" because in the service that I'm doing I'm using two devices, one of them, which is the microcontroller for what I'm creating the code, is powering the other and starts the communication. At the end of the service, I want low level at these interface' pins because left high level at these pins can make the other device not responde if I try to do the service twice in a succesive way. \$\endgroup\$ – Daniel Apr 15 at 17:13
  • \$\begingroup\$ "What makes you think the MCU does not "accept high impedance"?" The fact that it is mentioned to other Data Direction Registers, but is not declared to the data direction register that I'm using.To other ports it says : “1” causes the associated port pin to be an output and a “0” causes the associated pin to be a high-impedance input. But to the port S, that I'm using, it says :1 = Associated pin is configured as output. 0 = Associated pin is configured as input. \$\endgroup\$ – Daniel Apr 15 at 17:15
  • \$\begingroup\$ Are you setting the pins to input mode and disabling the resistor? No, I was only setting the pins to input, But I'm not sure if the pins are in this way, high logic level, because of the pull-up \$\endgroup\$ – Daniel Apr 15 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.