Configuring Pull Up/Pull Down for GPIO for MDB MPC57XX

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

Configuring Pull Up/Pull Down for GPIO for MDB MPC57XX

Jump to solution
2,869 Views
abhishek_kumar1
Contributor IV

Hello All

How can I configure the Weak Pull Up/ Pull Down of the GPIO block in Model Based Development (Simulink) blocks for the MPC57XX (V 3.0 release). I was not able to find a GPIO configuration block. 

Mico : MPC5744P

Matlab: 2018b

Software release: NXP Model Based Design Toolbox for MPC57xx (V 3.0)

Thank you for the help

1 Solution
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

PINS_DRV_SetPullSel(PORTC, 12, PORT_INTERNAL_PULL_NOT_ENABLED);

is an example for setting PUE = PUS = 0 for PTC12;

for other ports use: PORTA, PORTB, etc.

for pins use the number (e;g; for PTD5 use 5 as pin number).

As for question number 1, you can put your code (the SetPullSel call) into System Start Function Exit Code section to be sure that this is called after the initialization of the pin. You have to do this to make sure the resulting application is working as expected, and the PUE, PUS values are not overwritten by a GPIO block.

To sum it up, if you call PINS_DRV_SetPullSel(PORTC, 12, PORT_INTERNAL_PULL_NOT_ENABLED); in System Start Function Exit Code section of System Start block, you'll be able to change PUE and PUS for PTC12 pin.

Hope this helps,

Razvan.

View solution in original post

11 Replies
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

In the GPI Read block, you can find Pull Resistor Select from the mask:

pastedImage_1.png

Kind regards,

Razvan.

0 Kudos
2,534 Views
abhishek_kumar1
Contributor IV

Hello constantinrazvan.chivu

How can I configure the GPO for weak pull up and pull down (as shown in the picture below with PUS and PUE)?

pastedImage_1.png

Please help on on that. 

Kind Regards

Abhishek

0 Kudos
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

From the Pull resistor select you can select the following:

None - PUE 0, PUS 0

Pulldown - PUE 1, PUS 0

Pullup - PUE 1, PUS 1

If you select None this will do the following: PUE: 0 (disabled); PUS: 0 (no effect since PUE is disabled).

If you select Pulldown this will do the following: PUE: 1 (enabled); PUS: 0 (pulldown enabled)

If you select Pullup this will do the following: PUE: 1 (enabled); PUS: 1 (pullup enabled).

The code executed from the SDK is the following (code of interest in bold):

if (config->pullConfig != PORT_INTERNAL_PULL_NOT_ENABLED)
{
#ifdef FEATURE_SIUL2_HAS_PULL_KEEPER
pinsValues |= SIUL2_MSCR_PKE(1);
#endif
pinsValues |= SIUL2_MSCR_PUE(1);
pinsValues |= SIUL2_MSCR_PUS(config->pullConfig);
}
else
{
/* default disable pull resistors */
}

Kind regards,

Razvan.

0 Kudos
2,534 Views
abhishek_kumar1
Contributor IV

Dear constantinrazvan.chivu

pastedImage_1.png

The question is in regard to GPO. Can we change it for GPO.

Best Regards, 

Abhishek

0 Kudos
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

Sorry, did not notice you mentioned GPO in your last reply. For this you can not select anything. It is PORT_INTERNAL_PULL_NOT_ENABLED by default when output is used. If you want to be able to change it, we can use custom code blocks to add a call to an SDK function (PINS_SetPullSel) where you can set it to what you want. Let us know if this is what you want/need and we'll help you with this.

Kind regards,

Razvan.

0 Kudos
2,534 Views
abhishek_kumar1
Contributor IV

Dear constantinrazvan.chivu‌,

For the GPO's, we would like to change PUS and PUE bit. It would be great if a block for that can be created or you can guide us on how to do that for Model Based Design. 

0 Kudos
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

You'll have to use a System Start block to insert custom code into your model. In this block you can declare in the System Start Function Execution Code section the code you want to insert - e.g.:

PINS_DRV_SetPullSel(PORTA, 5, PORT_INTERNAL_PULL_DOWN_ENABLED); 

PINS_DRV_SetPullSel take the following parameters:

PORT_Type *const base --> here you'll declare the port you want to use (e.g. PORTA, PORTB, etc)

uint32_t pin --> here you'll enter the pin number (e.g.: 5 for PORTn5)

port_pull_config_t --> here you'll put one of the following (to control PUE and PUS)

PORT_INTERNAL_PULL_NOT_ENABLED PUE 0, PUS 0

PORT_INTERNAL_PULL_DOWN_ENABLED PUE 1, PUS 0

PORT_INTERNAL_PULL_UP_ENABLEDPUE 1, PUS 1

You'll just have to make sure this custom code is generated after the code from GPO blocks - you can control this by selecting block priorities and by placing in different parts of the System Start block (function declaration/execution/exit).

Kind regards,

Razvan.

0 Kudos
2,534 Views
abhishek_kumar1
Contributor IV

Dear constantinrazvan.chivu‌,

You'll just have to make sure this custom code is generated after the code from GPO blocks - you can control this by selecting block priorities and by placing in different parts of the System Start block (function declaration/execution/exit).

1. The priority of the "System Start Block" must be lower than which block? (I have attached a model for you, in original question)

2. In S32 Design Studio Documentation, I can not find parameter explaination for the PinSettings Function -> PinSettings documentation - 

    • PINS_DRV_SetPullSel(PORT_Type * const base,uint32_t pin,port_pull_config_t pullConfig)

(see below snapshot), I mean, I do not know what are the values of Port_Type for Pin PTC12 (as in the attached model)


pastedImage_3.png

0 Kudos
2,535 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

PINS_DRV_SetPullSel(PORTC, 12, PORT_INTERNAL_PULL_NOT_ENABLED);

is an example for setting PUE = PUS = 0 for PTC12;

for other ports use: PORTA, PORTB, etc.

for pins use the number (e;g; for PTD5 use 5 as pin number).

As for question number 1, you can put your code (the SetPullSel call) into System Start Function Exit Code section to be sure that this is called after the initialization of the pin. You have to do this to make sure the resulting application is working as expected, and the PUE, PUS values are not overwritten by a GPIO block.

To sum it up, if you call PINS_DRV_SetPullSel(PORTC, 12, PORT_INTERNAL_PULL_NOT_ENABLED); in System Start Function Exit Code section of System Start block, you'll be able to change PUE and PUS for PTC12 pin.

Hope this helps,

Razvan.

2,534 Views
abhishek_kumar1
Contributor IV

Dear constantinrazvan.chivu‌ 

Thank you. 

Just a last question.

Where can I find S32K SDK Manual, with precisely the information you gave me.

Where can i find the Function description with parameter values as I found the function but not the parameter values

0 Kudos
2,534 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

You can search PORTA or other port (Search is in the top right corner) - here you'll find the definition of PORTA as being

#define PORTA   ((PORT_Type *)(SIUL2_MSCR_BASE+0x00))

The rest are defined below this one.

The pin number is just a number - number of the pin - these don't have defines or something else.

The last one, the port_pull_config_t you can find by searching it:

Enumerator
PORT_INTERNAL_PULL_DOWN_ENABLED 

internal pull-down resistor is enabled.

PORT_INTERNAL_PULL_UP_ENABLED 

internal pull-up resistor is enabled.

PORT_INTERNAL_PULL_NOT_ENABLED 

internal pull-down/up resistor is disabled.

For information on how the function is implemented, you can find PINS_SetPullSel (as this is the function called by  PINS_DRV_SetPullSel) in the siul2_hw_access.h file: 

static inline void PINS_SetPullSel(PORT_Type * const base,
uint16_t pin,
port_pull_config_t pullConfig)
{
    uint32_t regVal;

    if (pullConfig == PORT_INTERNAL_PULL_NOT_ENABLED)
    {
        base->MSCR[pin] &= ~SIUL2_MSCR_PUE_MASK;
#ifdef FEATURE_SIUL2_HAS_PULL_KEEPER
       base->MSCR[pin] &= ~SIUL2_MSCR_PKE_MASK;
#endif
    }
    else
    {
        regVal = base->MSCR[pin];
#ifdef FEATURE_SIUL2_HAS_PULL_KEEPER
        regVal |= SIUL2_MSCR_PKE_MASK;
#endif
        regVal |= SIUL2_MSCR_PUE_MASK;
        regVal &= ~SIUL2_MSCR_PUS_MASK;
        regVal |= SIUL2_MSCR_PUS(pullConfig);
        base->MSCR[pin] = regVal;
    }
}

Hope this helps,

Razvan.

0 Kudos