Configuring UART module of DEVKIT-MPC5744P for freemaster utilization (S32DS)

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring UART module of DEVKIT-MPC5744P for freemaster utilization (S32DS)

Jump to solution
3,646 Views
Gayan_Niroshana
Contributor III

Hello,

I need some help with connecting DEVKIT-MPC5744P to Freemaster tool via on board OpenSDA interface.

DEVKIT-MPC5744P - https://www.nxp.com/design/development-boards/automotive-development-platforms/mpc57xx-mcu-platforms... 

I'm using DEVKIT-MPC5744P with S32 Design Studio for my projects and I want to use Freemaster tool for real time debugging. I couldn't find any example project for this board that utilize freemaster. As per to my knowledge, connecting the board to freemaster via on board OpenSDA interface should be done using UART module on the MC.

I could not find any example or documentation on how to configure UART module in order to connect to freemaster

Could someone please provide any example or documentation on this matter. 

Thanks and Regards,

Gayan.

0 Kudos
1 Solution
3,251 Views
iulian_stan
NXP Employee
NXP Employee

Update: I found the cause of this behavior - it is due to 2 interrupts enabled by SDK

  • Frame Error  (FEIE bit in LINIER register)
  • Buffer Overrun Error (BOIE bit in LINIER register)

FreeMASTER doe not need them, but once they are triggered, hardware communication is be stopped till corresponding flags are reset by the software. I did not see any option to disable these in Processor Expert GUI and did it manually

 

  REG_BIT_CLEAR32(&LINFlexD_0->LINIER, LINFlexD_LINIER_BOIE_MASK);
  REG_BIT_CLEAR32(&LINFlexD_0->LINIER, LINFlexD_LINIER_FEIE_MASK);

 

This should be the only change needed in your original example. I attached updated main file for reference.

View solution in original post

16 Replies
3,630 Views
iulian_stan
NXP Employee
NXP Employee

Hi @Gayan_Niroshana,

You can start by downloading FreeMASTER Communication Driver package available on FreeMASTER page  under Downloads tab.

Capture.PNG

This package include FreeMASTER Driver source code, documentation and example applications. By default it will extract all the content into C:\NXP\FreeMASTER_Serial_Communication_Driver_V2.0.

You can refer to the user guide located in doc\UserGuide for driver configuration. MPC57xx example applications can be found in examples\SCI_driver_examples\MPC57xx.

Additionally, there are a few articles explaining how to add FreeMASTER dependencies and configure the driver.

Hope it helps,
Iulian

3,521 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

I added Freemaster configurations to the example project adc_swtrigger_mpc5744P given in SDK PA RTM v3.0.3 Example Projects in S32 DS for PA. 

Example works fine on my board (DEVKIT-MPC5744P) without freemaster configs. But after I call FMSTR_Init() function in the code, even the example does not work on the dev board. I followed the steps described in this video(Though it describes for ARM MCs).

Communication Driver - Application Configuration 

What would be the reason for this?

And where can I find a tutorial on freemaster configurations for Power Architecture MCs.

I have attached the example project with freemaster configs added.

Best Regards,

Gayan.

 

 

0 Kudos
3,494 Views
iulian_stan
NXP Employee
NXP Employee

Unfortunately there is no separate guide for Power Architecture boards - the same steps should work in both cases (ARM and PA).

Currently I don't have a board to check your example, but I will try to get one and post an update here.

A few things I could suggest:

1. (before adding FreeMASTER) Add UART communication and confirm that your main application works and you are able to send/receive data over UART.
2. Add FreeMASTER (start with polling mode - FMSTR_POLL_DRIVEN, for test purpose call only FMSTR_Poll function in the main loop to ensure the communication works and then enable your application custom logic, also, I would call FMSTR_Init after board initialization functions - before the main loop).

Side notes: I saw that freemaster.h and freemaster_cfg.h are included twice in your project so I would remove include folder with both files as they are already included - the first one via FreeMASTER SDK and and the second one via Source folder).

0 Kudos
3,356 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan  ,

                               I used linflexd_uart_echo_mpc5774p example to test UART communication with PC. Example runs properly on the board and the dev-board can communicate with the PC. Then I included freemaster SDK to the same example and,

First - Only the FMSTR_Poll function with FMSTR_POLL_DRIVEN enabled. In this case example run properly and UART communication works. Freemaster app does not recognize the dev-board. 

Second - Included interrupt handler functions for freemaster , INT_SYS_InstallHandler(LINFLEXD0_RX_IRQn, FMSTR_Isr, NULL); INT_SYS_InstallHandler(LINFLEXD0_TX_IRQn, FMSTR_Isr, NULL); with FMSTR_SHORT_INTR enabled. This time even the example does not work; i.e. UART communication between PC and the dev-board isn't working.

I'm not sure these interrupt handler functions work with MPC5744P, as I picked them from the tutorial for ARM MCs.(As no tutorials available for PA MCs). What am I doing wrong here? 

I have attached the modified example program here for your reference.

Best Regards,

Gayan. 

0 Kudos
3,333 Views
iulian_stan
NXP Employee
NXP Employee

Hi @Gayan_Niroshana,

I was able to reproduce your issue. I do not see any problems in your code which make me think that there are some features enabled by the SDK that FreeMASTER does not handle correctly.

I will further look into it and let you know once there any updates.

Just to be on the safe side, could you tell me what board revision are you working with.

Iulian

3,294 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

Board revision - SCH 29333 REV E1 - 700 29333 Rev A

IMG_20211213_101030.jpg

Does the example work on boards and freemaster detects the board ?

Thanks & Regards,

Gayan.

0 Kudos
3,277 Views
iulian_stan
NXP Employee
NXP Employee

Hi @Gayan_Niroshana,

So far I could not find the root cause of the issue. It may take longer to find out why it behaves this way. In the meantime, I replaced the UART module generated with Processor Expert with a bare-metal implementation (see attached archive, it is based on the project you previously shared). I tested it on the same board you have, both in Poll-Driven and Interrupt Modes. You will find the UART initialization code in a separate UART_INIT function.

A few things to point out:

  • Regarding interrupt mode, beside installing interrupt handler I had to enable corresponding interrupts
    #if FMSTR_LONG_INTR || FMSTR_SHORT_INTR
      INT_SYS_EnableIRQ(LINFLEXD0_RX_IRQn);
      INT_SYS_EnableIRQ(LINFLEXD0_TX_IRQn);
      INT_SYS_InstallHandler(LINFLEXD0_RX_IRQn, FMSTR_Isr, NULL);
      INT_SYS_InstallHandler(LINFLEXD0_TX_IRQn, FMSTR_Isr, NULL);
    #endif​
  • In order to enable variable read functions, I made the following change in freemaster_cfg.h
    #define FMSTR_USE_READVAR      1 //0   /* enable read variable fast commands */
    #define FMSTR_USE_WRITEVAR     1 //0   /* enable write variable fast commands */
    #define FMSTR_USE_WRITEVARMASK 1 //0   /* enable write variable bits fast commands */​
     

Hope it helps,
Iulian

3,252 Views
iulian_stan
NXP Employee
NXP Employee

Update: I found the cause of this behavior - it is due to 2 interrupts enabled by SDK

  • Frame Error  (FEIE bit in LINIER register)
  • Buffer Overrun Error (BOIE bit in LINIER register)

FreeMASTER doe not need them, but once they are triggered, hardware communication is be stopped till corresponding flags are reset by the software. I did not see any option to disable these in Processor Expert GUI and did it manually

 

  REG_BIT_CLEAR32(&LINFlexD_0->LINIER, LINFlexD_LINIER_BOIE_MASK);
  REG_BIT_CLEAR32(&LINFlexD_0->LINIER, LINFlexD_LINIER_FEIE_MASK);

 

This should be the only change needed in your original example. I attached updated main file for reference.

3,214 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

Thank you very much. This Fix works properly. Now freemaster works with any project with processor expert.

Update: I found the cause of this behavior - it is due to 2 interrupts enabled by SDK

Is it freemaster SDK or MPC5744P_SDK_Z4 ?

Best Regards,

Gayan.

 

 

0 Kudos
3,193 Views
iulian_stan
NXP Employee
NXP Employee

Those flags are set by MPC5744P_SDK_Z4 functions. FreeMASTRE does not change any hardware configurations beyond reading and writing data (over UART in this particular case).

Just to be clear here - it is not an SDK issue, rather a compatibility problem. FreeMASTER SDK was developed and tested with bare-metal applications - I think there was an early version of MPC SDK, if any, at that moment, and as result some "glue code" is needed when FreeMASTER is used with target board SDK.

3,160 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

Thanks for the clarification.

One last problem here regarding bare-metal implementation of freemaster with projects that doesn't use MPC5744P_SDK_Z4 (without processor expert). I referred MPC5744P_EVB example given in the freemaster driver examples for S32DS PA and added necessary freemaster and UART configs to a simple blink example. 

Blink example runs properly with freemaster configs included but freemaster app doesn't detect the target.

Could you please tell me what I'm missing here. I have attached the program here for your reference. 

Best Regards,

Gayan.

 

 

   

0 Kudos
3,148 Views
iulian_stan
NXP Employee
NXP Employee

Hi @Gayan_Niroshana,

FreeMASTER does not detect the board because you use interrupt mode but do not enable nor set the corresponding interrupt handlers. Depending on which mode you'd like to use, here are the steps required to make it work:

  1. Poll Driven - switching the flag in freemaster_cfg.h will make it work
    #define FMSTR_LONG_INTR        0    /* complete message processing in interrupt */
    #define FMSTR_SHORT_INTR       0    /* SCI FIFO-queuing done in interrupt */
    #define FMSTR_POLL_DRIVEN      1    /* no interrupt needed, polling only */​
  2. Interrupt mode:
    • Enable SCI interrupts in MPC57xx__Interrupt_Init.c
      INTC_0.PSR[376].R = 0x8003; /* SCI RXI interrupt enable for core 0 */
      INTC_0.PSR[377].R = 0x8003; /* SCI TXI interrupt enable for core 0 */​
    • Assign interrupt handlers in intc_SW_mode_isr_vectors_MPC5744P.c
      extern void FMSTR_Isr(void);​
      this function is already defined in FreeMASTER
      (uint32_t) &FMSTR_Isr, /* Vector # 376 LINFlex_RXI LINFlex_0 */
      (uint32_t) &FMSTR_Isr, /* Vector # 377 LINFlex_TXI LINFlex_0 */​

BR,
Iulian

3,140 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

Yes of course, freemaster worked in polling only mode. Sorry, I forgot to mention it above. Couldn't find find where to check in order to set the required interrupt handlers, previously. 

Thank you very much for your support throughout the thread. It was most helpful.

Best regards,

Gayan.  

0 Kudos
3,543 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

Thank you very much for help. 

I found this example here; C:\NXP\FreeMASTER_Serial_Communication_Driver_V2.0\examples\SCI_driver_examples\MPC57xx\MPC574xP_EVB for my board. 

I'm currently using S32 DS v2.1. This example can't be compiled and it shows following errors. 

Screenshot 2021-11-29 175507.png

Is this a version mismatch of S32 DS or any other reason?

Thanks & Regards,

Gayan.

0 Kudos
3,498 Views
iulian_stan
NXP Employee
NXP Employee

Hi @Gayan_Niroshana,

I think the example project was indeed made with an older version with DS, but I was able to build it with S32 DS for PA 2.1 by updating the path to EWL library. The old version expects it to be in S32DS_Power_v2.1\S32DS\e200_ewl2, but it seems to be moved to S32DS_Power_v2.1\S32DS\build_tools\e200_ewl2.

Here are my changes:

1. Update Sysroot in Target Processor Settings:
Capture.PNG

 

2. Update Include Path and Symbols:
Capture1.PNG

 

One thing to note - as far as I know there were multiple revisions of the board - make sure PIN routing used in the project (periphinit.c) matches your board.

3,489 Views
Gayan_Niroshana
Contributor III

Hello @iulian_stan ,

I think the example project was indeed made with an older version with DS, but I was able to build it with S32 DS for PA 2.1 by updating the path to EWL library. The old version expects it to be inS32DS_Power_v2.1\S32DS\e200_ewl2,but it seems to be moved to S32DS_Power_v2.1\S32DS\build_tools\e200_ewl2.

Thanks you very much. These changes works fine. The program runs on the board now (Using S32DS v2.1) and the variables can be monitored using freemaster properly.

For the other case I'll make changes as per to your suggestions and give an update on that.

Thanks and regards,

Gayan. 

 

0 Kudos