cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Cube Monitor writing to a memory address

dq153252
Associate

I am trying to write to a memory location for a nucleo board. As far as I have seen so far the simplest way to do this is as follows:

dq153252_0-1716558520791.png

This can be problematic when the code changes and the memory address shifts for the variable I'm interested. I'm sure there is a simple way in which you can write to a variable in the same way that you read but I'm not sure how to do that. Would anyone be able to explain how to for me?

Thanks!

1 REPLY 1
stephane.legargeant
ST Employee

Hello

There is a graphical write node, but it is used from dashoard. If you want to write from the flow, I suggest a trick to  update more easily the addresses :  It is possible to store the variable adresses in the "flow context" and then to reuse it in the "template" nodes

If I have a variable "delayTimeOn", I can create a value "ad_delayTimeOn" in the flow context to store the address. then, I can reuse this variable to prepare the write message in the template node :

{
    "variablelist": [
        {
            "address": "{{flow.ad_delayTimeOn}}",
            "type":5,
            "value": "{{payload}}"
            }
        ],
        "accesspoint":0
}

 

The value "ad_delayTimeOn" in the flow context can be created with a change node. 

store_1_address.png

The "variables" nodes should have only one variable, and the address could be written in the flow context at init.

This solution is simple, but not convenient with multiples variables, as it requires multiple "Variables" nodes.

 

A better option is to use a function node to store all the variables addresses :

store_addresses.png

At init, the inject node send a msg to myVariables nodes and then myVariables will send the list of variables. The "function" node receive the list and creates the addresses references in the flow context

 The code in the function node is  :

store_addresses_function.png

// store the variable addresses in flow context
const varlist = msg.payload.variablelist;
for (var i = 0; i < varlist.length; i++) {
    node.error(varlist[i]);
    flow.set("ad_"+varlist[i].name, varlist[i].address);
}
return msg;

 It is a loop on all the variables in the varList, and it stores the information : add prefix "ad_" to the variable name and store the address. 

 

With this functions, all variables have thair addresses stored in the flow context.

If symbol file is changed, you just have to refresh the list in "myVariables" node.

 

I hope it will solve your question.  Please let us know if it is ok for you or if you need more information.

Best regards