Configure dual functions of same pin for s32k311

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

Configure dual functions of same pin for s32k311

Jump to solution
128 Views
tj_78
Contributor II

Hello, I need to configure dual functions of same pin for s32k311 and dynamically initialize one function during runtime. I tried using functional group and port containers to distinguish the pin functionality but i get the error "Mscr is repeated for 2 or more pins."

Here is my need, I want to initialize 2 pins as either UART or as GPIO based on the third pin. If the third PIN is high then i initialize UART and if low then as GPIO during run time. 

I have attached my test code. Please point me where I am doing wrong and help me achieve this requirement.

Thank you

0 Kudos
Reply
1 Solution
46 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @tj_78,

1. It is not necessary. You can simply initialize the next functional group, and the configuration will be overwritten. 

2. I think this issue comes from a generated problem inside Config Tools: 

Snag_1554aa3c.png

Could you check if you have any active problems in either the Pins, Clocks or Peripherals tab? 

Best regards,
Julián

View solution in original post

0 Kudos
Reply
6 Replies
93 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @tj_78,

I think your basic understanding for functional groups is correct. You can read the select pin and depending on that, initialize the others. For example, initialize your select pin (PTC16) and read it. If it is pressed, initialize the pins with your first functional group, otherwise, initialize it with your second functional group:

Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);

/* Wait for the button SW0 to be pressed */
if(Siul2_Dio_Ip_ReadPin(PIN_SELECT_PORT, PIN_SELECT_PIN) == 1)
{
	/* Wait the button SW0 to be released... */
	while(Siul2_Dio_Ip_ReadPin(PIN_SELECT_PORT, PIN_SELECT_PIN) == 1){}

	/* Initialize eIRQ & GPIO */
	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals_1, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals_1);

}
else
{
	/* Button not pressed; initialize UART */
	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals_2, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals_2);
}

However, in the Siul2_Port container for drivers, you must also separate the functional groups for each group in the "Pins" view:

Snag_fdb04b4.png

Please try to change this in your project, as I can see you have the three groups in one Port instance.

Best regards,
Julián

 

0 Kudos
Reply
88 Views
tj_78
Contributor II

Thank you @Julián_AragónM  for your response, i tried and now i am facing a different issue, in below image i created InitPeripherals2 and configured the Pins according to functional group created in pins tool

2.png

but if i change to InitPerpherals1 i get error saying name and portpin are same, i even changed the config set names to PortConfigset0, PortConfigset1 & PortConfigset2.

1.png

I am a bit confused as to what went wrong. Here is my Pin functional group names.

3.png

Before i posted this, i searched NXP community for this type of implementation and i found this article which looked similar so I followed the method used here: Model Based Design,

In that article the author used same Peripheral functional group name as _MBDT. 

0 Kudos
Reply
77 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @tj_78,

In order for the Port container to take the values from the "Pins" view, the functional group for "Pins" must be a combination of "Port Container name" + "_" + "Peripherals Functional Group name". For example, the default name for a project is "PortContainer_0_BOARD_InitPeripherals".

Snag_109fe1eb.png

You can keep "PortConfigSet" the same for each one, as well as "PortContainer_0":

Snag_10d35473.png

This way you can have 3 functional groups with different configuration for the same pin. I've attached the .mex so you can import it directly and see how to configure each functional group.

Best regards,
Julián

0 Kudos
Reply
56 Views
tj_78
Contributor II

It worked thank you @Julián_AragónM , I do have couple questions:
1. Is it necessary to de-initialize the current function of the pin before reinitializing it to other function?
5.png

2. Also when i tried on my actual project i facing the issue of files getting deleted. 

4.png

Before i split the Pin functionality into functional groups i already created the drivers and application, do you think i should clean the driver instances and add them on by one again?

Thank you.

0 Kudos
Reply
5 Views
tj_78
Contributor II
Thank you, I really appreciate your support. It helped me to move to next phase of development.
47 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @tj_78,

1. It is not necessary. You can simply initialize the next functional group, and the configuration will be overwritten. 

2. I think this issue comes from a generated problem inside Config Tools: 

Snag_1554aa3c.png

Could you check if you have any active problems in either the Pins, Clocks or Peripherals tab? 

Best regards,
Julián

0 Kudos
Reply