FreeMASTER embedded driver customizations

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

FreeMASTER embedded driver customizations

3,901 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

Now I'm runnining on the target and want to check the variables with freemaster.

But of course here I have also some Problems.

The Freemaster block implemented in S32K is brand new and contains enhancements what are only available on S32K products (and for all future releases)

In the old versions we will not find all these option. 

Nonetheless, you can modify the behavior by hand. If you go to ..\mctbx_Kinetis\mctbx_kv\src\FreeMaster_files you will find a file freemaster_cfg.h that is copied into the generated folder. You can change this file to configure the FreeMASTER to use RECORDER and INTERRUPTS.

Without having any changes on the freemaster_cfg.h file I was able to start the communication and changed the addresses of the variables to my modified model.

But in the "Recorder Properties" I saw that you used very much more samples than I'm able to use.

So it is not possible for me to record a long time like you did.

Maybe this depends on the required changings in the freemaster_cfg.h file so that there are more possible samples or are there any further options ?

You already shared a Header file with the changings, but I do not find it any more.

Would you share it again and explain what I have to change ?

Best regards

Leon

0 Kudos
Reply
12 Replies

3,150 Views
haoxue1027
Contributor IV

hidumitru-daniel.popa

I have a question about the ComputeElectricAngle modue.

pastedImage_1.png

 the value of Nmax in model workspace is 10000 ,  how to calculate the theta.

(speed_reference(rad/s) - Speed_Max(rad/s))*(2*pi/60)*PP*Nmax*(C_LST/2/pi)*(2^31)*pi?

I am confusing what exactly does this formula mean? 

can you help me answer it ,

thank you very much

best regards

hao

0 Kudos
Reply

3,150 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi Leon, 

In respect with the:

#define FMSTR_REC_BUFF_SIZE 12278 /* built-in buffer size */ 

You need to check the map file generated for the your application and check how much space you have available in RAM.

This is a parameter that depends on the data size of your application. Ideally you want this buffer to big as big as possible but keep in mind that RAM size is limited - therefore you need a trade off.

Once you found how much space you have available in RAM you can then allocate that space for the FreeMASTER buffer.

1) Is there an Option to increase the "current on-board Recorder Memory" and so the number of samples in freemaster or is it a fix value which depends on the embeeded Hardware (in my case HVP-MC3PH) ?

Nothing automatically. you will need to compute it as shown above.

2) The x-Axis is labeled with "Index" and not with "time". Also if I create a new recorder. How to Change this ?

Looks to a SW glitch probably due to import between different versions of FreeMASTER. Try to unselect and select back the option "Append units name to the label"

pastedImage_8.png

It seems to do the trick on my side - i hope it works for you too.

Best regards,
Daniel

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

Looks to a SW glitch probably due to import between different versions of FreeMASTER. Try to unselect and select back the option "Append units name to the Label"

This does not help...

xAxis is always labeled with "Index"

Also if I create a complete new model and configure the Recorder by my self

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

First successes !!!

After you made any changes in the freemaster_cfg.h file you simply have to Close Freemaster and open again to see the changings !

Also you have to delete the matlab generated <modelname> folder before the new compile. 

Then the xAxis is labeled with "Time" after making any changes in the graph Setup !

Also the changed FMSTR_REC_BUFF_SIZE 12278 is visible now in the Recorder Setting window and it seems to work with this value. But I didn't found the available ram in the map file yet.

So Good hint dumitru-daniel.popa‌ !!!

I have still These questions:

1) If I choose Short_INTR = 1 then the communication is not possible (with Poll Driven it works)

2) Where do I find the information how much space I have available in RAM exactly in the map file ?

3) For what are the Options Receive FIFO queue size, Support for Application Commands, Target-side address translation (TSA)) - should I use the Default KV values or your S32K ?

3,150 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi Leon, 

1) If I choose Short_INTR = 1 then the communication is not possible (with Poll Driven it works)

I'm not expert in FreeMASTER but i see there are some restrictions in using the drivers and the options from one platform to the other. Please check the manual attached.

2) Where do I find the information how much space I have available in RAM exactly in the map file ?

It is quite simple and depends on how you wish to tackle the problem.

  1. programmatic approach: you check where is the buffer defined: 
/* statically allocated recorder buffer (FMSTR_REC_OWNBUFF is FALSE) */
static FMSTR_U8 pcm_pOwnRecBuffer[FMSTR_REC_BUFF_SIZE];

The pcm_pOwnRecBuffer is statically defined in freemaster_rec.c file. This means it will be past of the BSS section for freemaster_rec.o

All you have to do now is to check the map file for mapping of BSS section of the freemaster_rec.o module

pastedImage_7.png

From linker file you compute how much space you still have available till the end of the segment

pastedImage_8.png

2. lazy approach: simply increase the size of the buffer and compare the memory files

pastedImage_9.png

Now increase the size until you get a linker error. You can do this very fast from Windows CMD by calling the *.bat file from the generated folder.

pastedImage_10.png

In this case i tried to allocate

/* built-in recorder buffer (use when FMSTR_REC_OWNBUFF is 0) */
#define FMSTR_REC_BUFF_SIZE            20000                     /* built-in buffer size */

and it failed, indicating the *.bss section and the memory regions involved.

3) For what are the Options Receive FIFO queue size, Support for Application Commands, Target-side address translation (TSA)) - should I use the Default KV values or your S32K ?

You should use the values from KV.

Best regards,

Daniel

0 Kudos
Reply

3,149 Views
lethuer
Contributor V

I'm not expert in FreeMASTER but i see there are some restrictions in using the drivers and the options from one platform to the other. Please check the manual attached.

Okay as you know I'm not en expert in freemaster, too.

I saw the Manual but it didn't helped me. I think the baud rate (communication Trouble shooting) should be okay, because it works in polling mode.

So I don't know what to Change for using the Interrupt mode with KV4. It would be really great you could check this ?

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

Okay with my changed Settings in freemaster_cfg.h file it does not work at the Moment and I got this error:

Can not detect board Information ! The communication will be paused.

Error code: 0x80000101 (Response timeout.)

You need to check the map file generated for the your application and check how much space you have available in RAM.

Where do I find this Information exactly in the map file ?

Maybe the buffer size is to high...

Thank you

Leon

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

I've setted back to the original value and also with this I got the error above.

#define FMSTR_REC_BUFF_SIZE 1024 /* built-in buffer size */ 

So I also tried the other variables (Receive FIFO queue size, Support for Application Commands, Target-side address translation (TSA)) which were different to your S32K freemaster_cfg.h file and I mentioned before

but without having success. so there are still some Problems and I get the same error message. What's wrong here ?

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

/******************************************************************************

* Select interrupt or poll-driven serial communication

******************************************************************************/

#define FMSTR_LONG_INTR 0 /* complete message processing in interrupt */

//old KV setting #define FMSTR_SHORT_INTR 0 /* SCI FIFO-queuing done in interrupt */

#define FMSTR_SHORT_INTR 1 /* SCI FIFO-queuing done in interrupt */

//old KV setting #define FMSTR_POLL_DRIVEN 1 /* no interrupt needed, polling only */

#define FMSTR_POLL_DRIVEN 0 /* no interrupt needed, polling only */

If I choose Poll_Driven = 1 with all the changings I made then the communication works.

If I choose Short_INTR = 1 then the communication is not possible

If I choose Long_INTR = 1 then the communication with the board seems to be okay but all selected variables have the value "?"

0 Kudos
Reply

3,150 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi Leon, 

Let's split the discussion since it has become hard to follow in the original thread.

Regarding the FreeMASTER configuration i've answered you here: https://community.nxp.com/thread/469150#comment-982190 

If you have further questions please use this new thread for asking FreeMASTER related stuff.

Best regards,
Daniel

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

Thank you dumitru-daniel.popa !

Didn't found your post yesterday.

But in the "Recorder Properties" I saw that you used very much more samples than I'm able to use.

So it is not possible for me to record a long time like you did.

Maybe this depends on the required changings in the freemaster_cfg.h file so that there are more possible samples or are there any further options ?

I‘ve attached a picture of the freemaster window what I‘m Talking about.

1) Is there an Option to increase the "current on-board Recorder Memory" and so the number of samples in freemaster or is it a fix value which depends on the embeeded Hardware (in my case HVP-MC3PH) ?

2) The x-Axis is labeled with "Index" and not with "time". Also if I create a new recorder. How to Change this ?

Best regards

Leon

0 Kudos
Reply

3,150 Views
lethuer
Contributor V

I've compared the original KV4x freemaster_cfg.h file which is copied during the code Generation and made the following changings in reference to your post from shared M5 freemaster_cfg.h file. https://community.nxp.com/thread/469150#comment-982190

/******************************************************************************

* Select interrupt or poll-driven serial communication

******************************************************************************/

#define FMSTR_LONG_INTR 0 /* complete message processing in interrupt */

//old KV setting #define FMSTR_SHORT_INTR 0 /* SCI FIFO-queuing done in interrupt */

#define FMSTR_SHORT_INTR 1 /* SCI FIFO-queuing done in interrupt */

//old KV setting #define FMSTR_POLL_DRIVEN 1 /* no interrupt needed, polling only */

#define FMSTR_POLL_DRIVEN 0 /* no interrupt needed, polling only */

/* built-in recorder buffer (use when FMSTR_REC_OWNBUFF is 0) */

//old KV setting #define FMSTR_REC_BUFF_SIZE 1024 /* built-in buffer size */

#define FMSTR_REC_BUFF_SIZE 12278 /* built-in buffer size */

/* recorder time base, specifies how often the recorder is called in the user app. */

//old KV setting #define FMSTR_REC_TIMEBASE FMSTR_REC_BASE_MILLISEC(0) /* 0 = "unknown" */

#define FMSTR_REC_TIMEBASE FMSTR_REC_BASE_MICROSEC(100) /* 0 = "unknown" */

 

------------------------------------------------------------------------------------------------- 

I also found this differences between the both files. Are there any further changings required or do I have to Change only the ones you explained in your post (see above) ?

/******************************************************************************

* Receive FIFO queue size (use with FMSTR_SHORT_INTR only)

******************************************************************************/

//KV4:

#define FMSTR_COMM_RQUEUE_SIZE 32 /* set to 0 for "default" */

//S32K:

#define FMSTR_COMM_RQUEUE_SIZE 0 /* set to 0 for "default" */

/*****************************************************************************

* Support for Application Commands

******************************************************************************/

//KV4:

#define FMSTR_USE_APPCMD 1 /* enable/disable App.Commands support */

#define FMSTR_APPCMD_BUFF_SIZE 32 /* App.Command data buffer size */

#define FMSTR_MAX_APPCMD_CALLS 4 /* how many app.cmd callbacks? (0=disable) */

//S32K:

#define FMSTR_USE_APPCMD 0 /* enable/disable App.Commands support */

#define FMSTR_APPCMD_BUFF_SIZE 0 /* App.Command data buffer size */

#define FMSTR_MAX_APPCMD_CALLS 0 /* how many app.cmd callbacks? (0=disable) */

/*****************************************************************************

* Target-side address translation (TSA)

******************************************************************************/

//KV4:

#define FMSTR_USE_TSA 0 /* enable TSA functionality */

#define FMSTR_USE_TSA_SAFETY 1 /* enable access to TSA variables only */

#define FMSTR_USE_TSA_INROM 1 /* TSA tables declared as const (put to ROM) */

//S32K:

#define FMSTR_USE_TSA 0 /* enable TSA functionality */

#define FMSTR_USE_TSA_SAFETY 0 /* enable access to TSA variables only */

#define FMSTR_USE_TSA_INROM 0 /* TSA tables declared as const (put to ROM) */

0 Kudos
Reply