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
已解决! 转到解答。
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:
Could you check if you have any active problems in either the Pins, Clocks or Peripherals tab?
Best regards,
Julián
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:
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
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
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.
I am a bit confused as to what went wrong. Here is my Pin functional group names.
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.
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".
You can keep "PortConfigSet" the same for each one, as well as "PortContainer_0":
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
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?
2. Also when i tried on my actual project i facing the issue of files getting deleted.
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.
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:
Could you check if you have any active problems in either the Pins, Clocks or Peripherals tab?
Best regards,
Julián