How can I add FreeMASTER to my project?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How can I add FreeMASTER to my project?

2,153 次查看
trunie1
Contributor III

I want to implement BLDC 6 Step control.
- MCSPTE1AK344 development board used
- 6 PWM outputs used
- 3 digital inputs used for Hall Sensor value
- I opened and worked on the PWM example project

pwm example.png

And I am planning to use FreeMASTER to check the operation of PWM output and digital input in the above project.

How can I add FreeMASTER to the above project?

※ I opened the FreeMASTER example and confirmed that FreeMASTER is working

FreeMASTER.png

0 项奖励
回复
5 回复数

2,142 次查看
iulian_stan
NXP Employee
NXP Employee

Hi @trunie1,

Here are the steps needed to add FreeMASTER Driver into your project:

  1. Attach FreeMASTER SDK to your PWM project
    Capture.PNG

     (this will add links to FreeMASTER source and header files to your PWM project).

  2. Configure UART pins, clock, peripheral - this is an external step (FreeMASTER does not configure the UART)
    During UART configuration, depending on the desired communication mode you may set FMSTR_SerialIsr as the UART interrupt handler. For communication mode see freemaster_cfg.h
    #define FMSTR_LONG_INTR   0   // If 1 FMSTR_SerialIsr should handle the UART interrupt
    #define FMSTR_SHORT_INTR  1   // If 1 FMSTR_SerialIsr should handle the UART interrupt
    #define FMSTR_POLL_DRIVEN 0   // Does not require setting UART interrupt


    Next steps are similar to the FreeMASTER example application:

  3. Add the following includes to our main application:
    #include "freemaster.h"
    #include "freemaster_s32k3xx_lpuart.h"​
  4.  Initialize FreeMASTER Driver after board initilaization
    /* Set UART base address */
    FMSTR_SerialSetBaseAddress((FMSTR_ADDR)LPUART_6_BASE);
    
    /* Initialize FreeMASTER */
    FMSTR_Init();​
  5. Periodically call FMSTR_Poll function (either in an infinite loop in your main function or a timer interrupt)
    for (;;) {
      FMSTR_Poll();
    }

 

Hope it helps,
Iulian

0 项奖励
回复

2,107 次查看
trunie1
Contributor III

First of all, I would like you to explain process 2 in detail. I don't understand what I should do.

And when I build after adding the code from steps 3 to 5, the following error occurs.
error : ../src/main.c:132:44: error: 'LPUART_6_BASE' undeclared (first use in this function); did you mean 'LPUART6_CLK'?

In this regard, the FMSTR_SerialSetBaseAddress((FMSTR_ADDR)LPUART_2_BASE) function is used in the fmstr_uart_s32k344 example project of S32DS. So I searched for the location where the 'LPUART_2_BASE' parameter was declared.
- 'LPUART_2_BASE' : S32K344.h

The above S32K344.h file did not exist in my project (Pwm_example_S32K344 used).
To resolve the build error, should I copy the above header file and add it inside the project folder?

[error happened]

1. error.png

[S32K344.h at fmstr_uart_s32k344 example project]

2. S32K344.h.png

0 项奖励
回复

2,095 次查看
iulian_stan
NXP Employee
NXP Employee

RTD (Real Time Drivers) has a slight different project structure. The platform specific header files are stored in "C:\NXP\S32DS.3.5\S32DS\software\PlatformSDK_S32K3\RTD\BaseNXP_TS_T40D34M30I0R0\header"

Capture.PNG

 

LPUART specific register information is defined in S32K344_LPUART.h:

Capture2.PNG

 

You can use numeric value of the UART instance or a macro  IP_LPUART_X_BASE (in the later case you need to include S32K344_LPUART.h header file.)

0 项奖励
回复

2,078 次查看
trunie1
Contributor III

Hello.

I solved the error by including the S32K344_LPUART.h file.

However, I don't know how to configure UART pins, clock, and peripherals. I would like you to explain in detail.

The current situation is as follows.
1. Build without UART code of frmst_uart_s32k344 example project
 1) FreeMASTER is connected
 2) When I add a variable declared in main.c, the message 'Symbol not found' appears.

1. error happen.png

2. An error occurs when building by adding the UART code of frmst_uart_s32k344 example project

2. error.png

0 项奖励
回复

2,038 次查看
iulian_stan
NXP Employee
NXP Employee

Hi @trunie1,

IClock, Pins and UART configuration is done via UI using S32 Configuration Tools. It is quite intuitive and has help (F1) information.

Clock (most likely it is already configured for you):

Capture.PNG

 

Pins:

Capture.PNG

 

Peripherals:

Capture.PNG

 

Here you will need to add/update the following 3 MCAL components: Uart, Port (for SIUL config) and Platform (for UART interrupt). You can use Uart_Example_S32K344 example project as reference:

Capture.PNG

You can find more information about Configuration Tools in "C:\NXP\S32DS.3.5\Release_Notes\S32_Configuration_Tools_Release_Notes.pdf". For further assistance on configuration please refer to S32 Design Studio community space.

 

1. FreeMASTER throws that error due to missing symbolic information. This information is extracted from the DWARF section of your ELF file. Refer to "Symbol files" (ch. 5.2 of the User Manual).

Capture.PNG

IF you already provided it, you can check the list of all extracted symbols by pressing the "View" button to double check whether that symbol was extracted.

Note: the ELF file should be build with enabled debug information.

2. Those errors are caused by helper functions/macros are not defined in your project. They are defined inside FreeMASTER project (not part of RTD/SDK). Even if you copy-paste the header file where those are defined into your project, it won't work because of different register notation (you saw it in case of UART base address).

 

0 项奖励
回复