<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Freemaster witch packed struct pointers in FreeMASTER</title>
    <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1489481#M1056</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have used freemaster succesfully so far, but now I have a problem with a PACKED struct pointers. Freemaster shown values are not correct.&lt;/P&gt;&lt;P&gt;The struct is the following where MinasOutput*&amp;nbsp; and MinasInput* are two pointers to PACKED structs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;typedef struct
{
uint16 slaveNum; /*&amp;lt;! Numero dello slave del motore. */
MBDLT25BF_STATE state; /*&amp;lt;! Stato attuale del motore. */
MinasOutput* mbdlt25bfOut; /*&amp;lt;! Puntatore alla struct dei RxPDO. */
MinasInput* mbdlt25bfIn; /*&amp;lt;! Puntatore alla struct dei TxPDO. */
osal_timert tself; /*&amp;lt;! Timer utilizzato per controllare la buona riuscita di un'operazione. */

int acc, dec, max, duration;
DIRECTION direction;
int counter;
}tMbdlt25bf;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On freemaster_cfg.c I did:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FMSTR_TSA_RO_VAR(mbdlt25bf, FMSTR_TSA_USERTYPE(tMbdlt25bf))

FMSTR_TSA_STRUCT(tMbdlt25bf)
FMSTR_TSA_MEMBER(tMbdlt25bf, state, FMSTR_TSA_USERTYPE(MBDLT25BF_STATE))
FMSTR_TSA_MEMBER(tMbdlt25bf, acc, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, dec, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, duration, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, max, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, counter, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfOut, FMSTR_TSA_USERTYPE(MinasOutput))
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfIn, FMSTR_TSA_USERTYPE(MinasInput))

FMSTR_TSA_STRUCT(MinasOutput)
FMSTR_TSA_MEMBER(MinasOutput, controlword, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, operation_mode, FMSTR_TSA_SINT8)
FMSTR_TSA_MEMBER(MinasOutput, target_torque, FMSTR_TSA_SINT16)
FMSTR_TSA_MEMBER(MinasOutput, max_torque, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, target_position, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(MinasOutput, max_motor_speed, FMSTR_TSA_UINT32)
FMSTR_TSA_MEMBER(MinasOutput, touch_probe_function, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, target_velocity, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(MinasOutput, position_offset, FMSTR_TSA_SINT32)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an alternative solution instead of coping struct field values to some variables and share the latters with freemaster tool ?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jul 2022 12:26:52 GMT</pubDate>
    <dc:creator>Davidino</dc:creator>
    <dc:date>2022-07-14T12:26:52Z</dc:date>
    <item>
      <title>Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1489481#M1056</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have used freemaster succesfully so far, but now I have a problem with a PACKED struct pointers. Freemaster shown values are not correct.&lt;/P&gt;&lt;P&gt;The struct is the following where MinasOutput*&amp;nbsp; and MinasInput* are two pointers to PACKED structs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;typedef struct
{
uint16 slaveNum; /*&amp;lt;! Numero dello slave del motore. */
MBDLT25BF_STATE state; /*&amp;lt;! Stato attuale del motore. */
MinasOutput* mbdlt25bfOut; /*&amp;lt;! Puntatore alla struct dei RxPDO. */
MinasInput* mbdlt25bfIn; /*&amp;lt;! Puntatore alla struct dei TxPDO. */
osal_timert tself; /*&amp;lt;! Timer utilizzato per controllare la buona riuscita di un'operazione. */

int acc, dec, max, duration;
DIRECTION direction;
int counter;
}tMbdlt25bf;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On freemaster_cfg.c I did:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FMSTR_TSA_RO_VAR(mbdlt25bf, FMSTR_TSA_USERTYPE(tMbdlt25bf))

FMSTR_TSA_STRUCT(tMbdlt25bf)
FMSTR_TSA_MEMBER(tMbdlt25bf, state, FMSTR_TSA_USERTYPE(MBDLT25BF_STATE))
FMSTR_TSA_MEMBER(tMbdlt25bf, acc, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, dec, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, duration, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, max, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, counter, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfOut, FMSTR_TSA_USERTYPE(MinasOutput))
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfIn, FMSTR_TSA_USERTYPE(MinasInput))

FMSTR_TSA_STRUCT(MinasOutput)
FMSTR_TSA_MEMBER(MinasOutput, controlword, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, operation_mode, FMSTR_TSA_SINT8)
FMSTR_TSA_MEMBER(MinasOutput, target_torque, FMSTR_TSA_SINT16)
FMSTR_TSA_MEMBER(MinasOutput, max_torque, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, target_position, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(MinasOutput, max_motor_speed, FMSTR_TSA_UINT32)
FMSTR_TSA_MEMBER(MinasOutput, touch_probe_function, FMSTR_TSA_UINT16)
FMSTR_TSA_MEMBER(MinasOutput, target_velocity, FMSTR_TSA_SINT32)
FMSTR_TSA_MEMBER(MinasOutput, position_offset, FMSTR_TSA_SINT32)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an alternative solution instead of coping struct field values to some variables and share the latters with freemaster tool ?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 12:26:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1489481#M1056</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-14T12:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490131#M1059</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;SPAN&gt;Davidino,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the problem is not is the packed structures, but in the fact that you only have pointers to them. You should treat this type as FMSTR_TSA_POINTER which is in fact just a 32bit number.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you indeed need to read/write the structure members, it would be best to include them directly into the top level structure (not via pointers) or at least give them a fixed (static/global) addresses and access them individually.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There is also a solution for you to access the two child structures indirectly and without a fixed pointers, but this is more complex and will require some small JavaScript support. Let me know if this is needed, I can guide you through necessary&amp;nbsp;steps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;BR /&gt;Michal&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 07:29:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490131#M1059</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-15T07:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490186#M1060</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;thank you very much for your answer. Among the several solution that you proposed me I'd go with the simpler (the one using FMSTR_TSA_POINTER I think) as I don't need to write the fields, only reading is requested.&lt;/P&gt;&lt;P&gt;I cannot make them as structs, as the struct memory locations are shared through an union to an array; and I cannot change that part.&lt;/P&gt;&lt;P&gt;CAn you provide me an example about the simpler approach?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 08:45:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490186#M1060</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-15T08:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490255#M1061</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;the simpler way without JavaScript involved:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;In TSA table, have the mbdlt25bfOut member defined as FMSTR_TSA_POINTER&lt;/LI&gt;
&lt;LI&gt;In FreeMASTER, create a variable (4-byte unsigned) to read this member "mbdlt25bf.mbdlt25bfOut"&lt;/LI&gt;
&lt;LI&gt;You can put this variable to a Watch to make sure the variable is readable. The value of the variable should be an address of the referenced structure in memory.&lt;/LI&gt;
&lt;LI&gt;Note that you should never change the pointer in your application. It should be constant value.&lt;/LI&gt;
&lt;LI&gt;You can set sampling period of this variable to "once"&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Now you can access e.g. the "mbdlt25bf.mbdlt25bfOut-&amp;gt;controlword" member:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Define a new variable with this address: valueof(mbdlt25bf.mbdlt25bfOut) + offsetof(MinasOutput, controlword)&lt;/LI&gt;
&lt;LI&gt;You need to set the size manually to 2 bytes (controlword is uint16).&lt;/LI&gt;
&lt;LI&gt;Note that when FreeMASTER reads the variable, it first reads the "mbdlt25bf.mbdlt25bfOut", then it evaluates the value (valueof() operator) and uses it to calculate an address of the controlword member.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Harder, but more effective way with JavaScript. JavaScript is able to programmatically retrieve an address of the mbdlt25bf.mbdlt25bfOut pointer and define a new symbol properly typed as a pointer to MinasOutput. The members of the referenced structure than appear automatically in the FreeMASTER symbols list:&lt;/P&gt;
&lt;PRE&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body onload="main()"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;OBJECT id="pcm" height="0" width="0" classid="clsid:48A185F1-FFDB-11D3-80E3-00C04F176153"&amp;gt;&lt;BR /&gt;&amp;lt;/OBJECT&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;function main()&lt;BR /&gt;{&lt;BR /&gt;    if(pcm.ReadUIntVariable("mbdlt25bf.mbdlt25bfOut", 4))&lt;BR /&gt;    {&lt;BR /&gt;        if(pcm.DefineSymbol("mbdlt25bf.mbdlt25bfOut&lt;STRONG&gt;_ptr&lt;/STRONG&gt;", pcm.LastVariable_vValue, "MinasOutput*", 4))&lt;BR /&gt;            console.log("mbdlt25bf.mbdlt25bfOut_ptr symbol defined at address" + pcm.LastVariable_vValue);&lt;BR /&gt;        else&lt;BR /&gt;            console.log("Error defining the mbdlt25bf.mbdlt25bfOut_ptr");&lt;BR /&gt;    }&lt;BR /&gt;    else&lt;BR /&gt;    {&lt;BR /&gt;        console.log("Error reading mbdlt25bf.mbdlt25bfOut");&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 10:16:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1490255#M1061</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-15T10:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492460#M1064</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;thank you for your answer. I searched for some piece of code that uses FMSTR_TSA_POINTER but it doesn't exist, neither in SDK Freemaster example nor in documentation. How do I substitute&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfOut, FMSTR_TSA_USERTYPE(MinasOutput))
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfIn, FMSTR_TSA_USERTYPE(MinasInput))&lt;/LI-CODE&gt;&lt;P&gt;with FMSTR_TSA_POINTER considering that its definition is&lt;/P&gt;&lt;P&gt;"extern FMSTR_TSA_CDECL char FMSTR_TSA_POINTER[]"?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:45:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492460#M1064</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-20T12:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492472#M1065</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;it should be a simply:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfOut, FMSTR_TSA_POINTER)
FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfIn, FMSTR_TSA_POINTER)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or you could also replace it with just FMSTR_TSA_UINT32 as the pointer is 4 bytes long and our intent is just to read the pointer value.&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Michal&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:56:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492472#M1065</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-20T12:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492549#M1066</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;thank you for your message. I did as you showed me and FMSTR_TSA_POINTER is ok.&lt;BR /&gt;Now I have a problem with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;valueof(mbdlt25bf.mbdlt25bfOut) + offsetof(MinasOutput, controlword)&lt;/LI-CODE&gt;&lt;P&gt;I didn't find any info about that on internet except that it's a new feature of Freemaster version 3.1.4. I can't find out how to implement it. Besides searching for the functions offsetof and valueof in the code, I couldn't find them.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Could you explain me?&lt;/P&gt;&lt;P&gt;Thank you for your cooperation.&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:42:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1492549#M1066</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-20T14:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1493571#M1067</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;both &lt;STRONG&gt;valueof&lt;/STRONG&gt; and &lt;STRONG&gt;offsetof&lt;/STRONG&gt; operators can be used when defining a FreeMASTER variable object. Each FreeMASTER variable needs to know the address (in target MCU memory space) from where the FreeMASTER could read the required value. Normally, you specify either a direct numeric address or you can use a C-language symbol obtained by reading application’s ELF file. In more advanced way, the TSA-defined symbols can be used – but in any case, such symbol resolves to a single constant numeric address.&lt;/P&gt;
&lt;P&gt;In your case, the address of the &lt;STRONG&gt;mbdlt25bf.mbdlt25bfOut-&amp;gt;controlword&lt;/STRONG&gt; is not statically available in ELF file nor in the TSA because the &lt;STRONG&gt;mbdlt25bfOut&lt;/STRONG&gt; is a pointer whose value can be dynamically changed in the application. This is why you need to define the address using the expression:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;valueof(mbdlt25bf.mbdlt25bfOut) + offsetof(MinasOutput, controlword)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;valueof&lt;/STRONG&gt; operator reads a value of the given FreeMASTER variable (which must exist in FreeMASTER project, it can be sampled “once” as we assume the pointer will not change).&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;offsetof&lt;/STRONG&gt; operator returns an offset of a given member withing a structure type.&lt;/P&gt;
&lt;P&gt;All together, this expression returns an address of &lt;STRONG&gt;mbdlt25bf.mbdlt25bfOut-&amp;gt;controlword&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In FreeMASTER, there is a hint describing the operators:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichalH_1-1658434012273.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/187454iC8CCF2D93BF1EF12/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichalH_1-1658434012273.png" alt="MichalH_1-1658434012273.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Michal&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 20:07:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1493571#M1067</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-21T20:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1493910#M1068</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thank you for your patience and support. I installed the new freemaster version 3.2 so that it's possible to define expression for the variable addresses. My freemaster_cfg.c now looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;	FMSTR_TSA_STRUCT(tMbdlt25bf)
	FMSTR_TSA_MEMBER(tMbdlt25bf, state, FMSTR_TSA_USERTYPE(MBDLT25BF_STATE))
	FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfOut, FMSTR_TSA_POINTER)
	FMSTR_TSA_MEMBER(tMbdlt25bf, mbdlt25bfIn, FMSTR_TSA_POINTER)

	FMSTR_TSA_STRUCT(MinasOutput)
	FMSTR_TSA_MEMBER(MinasOutput, controlword, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasOutput, operation_mode, FMSTR_TSA_SINT8)
	FMSTR_TSA_MEMBER(MinasOutput, target_torque, FMSTR_TSA_SINT16)
	FMSTR_TSA_MEMBER(MinasOutput, max_torque, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasOutput, target_position, FMSTR_TSA_SINT32)
	FMSTR_TSA_MEMBER(MinasOutput, max_motor_speed, FMSTR_TSA_UINT32)
	FMSTR_TSA_MEMBER(MinasOutput, touch_probe_function, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasOutput, target_velocity, FMSTR_TSA_SINT32)
	FMSTR_TSA_MEMBER(MinasOutput, position_offset, FMSTR_TSA_SINT32)

	FMSTR_TSA_STRUCT(MinasInput)
	FMSTR_TSA_MEMBER(MinasInput, error_code, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasInput, statusword, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasInput, operation_mode, FMSTR_TSA_USERTYPE(PDS_OPERATION))
	FMSTR_TSA_MEMBER(MinasInput, position_actual_value, FMSTR_TSA_SINT32)
	FMSTR_TSA_MEMBER(MinasInput, velocity_actual_value, FMSTR_TSA_SINT32)
	FMSTR_TSA_MEMBER(MinasInput, torque_actual_value, FMSTR_TSA_SINT16)
	FMSTR_TSA_MEMBER(MinasInput, touch_probe_status, FMSTR_TSA_UINT16)
	FMSTR_TSA_MEMBER(MinasInput, touch_probe_posl_pos_value, FMSTR_TSA_SINT32)
	FMSTR_TSA_MEMBER(MinasInput, digital_inputs, FMSTR_TSA_UINT32)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing that I didn't tell you is that my mbdlt25bf struct is actually an array of struct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tMbdlt25bf mbdlt25bf[ARRAY_SIZE_MOTORS];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've one more issue where I'm trying to get the value stored in the variable &lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut-&amp;gt;controlWord.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The address that I wrote is: &lt;STRONG&gt;valueof(mbdlt25bf[7].mbdlt25bfOut) + offsetof(MinasOutput, controlword),&lt;/STRONG&gt; as shown in the picture.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Davidino_1-1658478758280.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/187512iC27E3E8DC0270977/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Davidino_1-1658478758280.png" alt="Davidino_1-1658478758280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see the value doesn't get updated. Can you advise me?&lt;/P&gt;&lt;P&gt;Thank you again for your cooperation.&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 08:39:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1493910#M1068</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-22T08:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1494080#M1070</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;you should first make sure that the FreeMASTER determines the address of&amp;nbsp;&lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut&amp;nbsp;&lt;/STRONG&gt;member correctly. One way of verifying that would be to examine this member in a debugger or print it to console by the MCU application. In any case, the address of this element should match what FreeMASTER prints in the Variable definition dialog (in my example it prints an address of variable named "var16").&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichalH_0-1658495620255.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/187554iA17624C672B0A466/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichalH_0-1658495620255.png" alt="MichalH_0-1658495620255.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;&lt;STRONG&gt;mbdlt25bf&amp;nbsp;&lt;/STRONG&gt;is really an array, the FreeMASTER should understand it and calculate a correct address. Basically, to access the &lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut &lt;/STRONG&gt;member, the FreeMASTER calculates something like:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;mbdlt25bf + 7*sizeof(tMbdlt25bf) + offsetof(tMbdlt25bf,&amp;nbsp;mbdlt25bfOut)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is a fixed address (not runtime) so FreeMASTER should be able to show it to you in the Variable definition dialog. You should be able to see the address just like I see it for my "var16" above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you are sure the above is correct, define a FreeMASTER variable named&amp;nbsp;&lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut&amp;nbsp;&lt;/STRONG&gt;with the same address specification and size=4 bytes. You should be able to put this variable into a Watch and see the value of the &lt;STRONG&gt;mbdlt25bfOut&amp;nbsp;&lt;/STRONG&gt;pointer.&lt;/P&gt;
&lt;P&gt;Last, you will be able to define a new FreeMASTER variable named&amp;nbsp;&lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut-&amp;gt;controlword&amp;nbsp;&lt;/STRONG&gt; with address defined by the runtime expression as we discussed earlier:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;valueof(mbdlt25bf[7].mbdlt25bfOut) + offsetof(MinasOutput, controlword)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This address is calculated in run-time, because FreeMASTER must first read the &lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut&amp;nbsp;&lt;/STRONG&gt;variable and add the fixed &lt;STRONG&gt;controlword&lt;/STRONG&gt; member offset to the obtained value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_____________________________&lt;/P&gt;
&lt;P&gt;As you can see, dealing with pointers in FreeMASTER is tricky. I would advise again not to declare the &lt;STRONG&gt;mbdlt25bfOut&lt;/STRONG&gt; member as a pointer to a &lt;STRONG&gt;MinasOutput&lt;/STRONG&gt; structure, but to include the full structure directly. This will enable FreeMASTER to calculate address of&amp;nbsp;&lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut.controlword&amp;nbsp;&lt;/STRONG&gt;statically and access the &lt;STRONG&gt;controlword&lt;/STRONG&gt; member directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Michal&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 13:31:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1494080#M1070</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-22T13:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497344#M1078</link>
      <description>&lt;P&gt;&lt;U&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt; ,&lt;/U&gt;&lt;/P&gt;&lt;P&gt;thanks for your detailed answer. I can confirm you that the address stored in &lt;STRONG&gt;mbdlt25bf[7].mbdlt25bfOut&amp;nbsp;&lt;/STRONG&gt;is correct (green box in the picture) as it is confirmed in MCUXpresso with the debugger. However, the address&amp;nbsp;&lt;STRONG&gt;valueof(mbdlt25bf[7].mbdlt25bfOut)&lt;/STRONG&gt; isn't computed correctly as it shows the question mark (red box in the picture). I don't understand why this happens.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nuova immagine bitmap.bmp" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/188271i4FC5FCEEAA17F2D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nuova immagine bitmap.bmp" alt="Nuova immagine bitmap.bmp" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;P.S. In case this method doesn't work, I'll create copy of mbdlt25bfOut and mbdlt25bfIn structs and ciclically update the values for the solely purpose of seeing them on Freemaster.&lt;BR /&gt;Giving up on struct pointers would affect my program performances.&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;&lt;P&gt;Davidino&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 12:56:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497344#M1078</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-28T12:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497784#M1079</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;A id="link_6" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/179182" target="_self" aria-label="View Profile of Davidino"&gt;&lt;SPAN class=""&gt;Davidino,&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;with TSA, the FreeMASTER driver in the MCU actively monitors any access and it denies reading or writing to a memory which is not "described" by at least one TSA entry. It also protects a write access to memory locations marked in TSA as RO (Read-only).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You can turn this protection off (set FMSTR_USE_TSA_SAFETY to 0). This will keep the TSA basic functionality, but will disable the memory access checks.&lt;/P&gt;
&lt;P&gt;I think this is the reason for the question mark. If not, let me know and we will investigate further.&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Michal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 06:30:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497784#M1079</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2022-07-29T06:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Freemaster witch packed struct pointers</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497810#M1080</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34487"&gt;@MichalH&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;Thank you very much for your support and patience!&lt;/P&gt;&lt;P&gt;That was the solution.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 07:04:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Freemaster-witch-packed-struct-pointers/m-p/1497810#M1080</guid>
      <dc:creator>Davidino</dc:creator>
      <dc:date>2022-07-29T07:04:27Z</dc:date>
    </item>
  </channel>
</rss>

