Hello,
I am using the Devkit MPC5744P and the Model Based Design Toolbox 3.0.0.
I can not find the MSR register using the "Read Registers Block".
Is there a way to read it in the Model Based Design?
Kind Regards, Rafael
Solved! Go to Solution.
Hello rafael.barbosa@chassisbrakes.com,
Our Read Registers Block provides access only to peripherals registers. The register you want to read is critical and is one of the process control registers in the PowerPC architecture.
However, this register may be read using the mfmsr assembly instruction. For this, you need to insert some custom code.
One way is to create your own S-Function to return the mfmsrValue variable.
volatile uint32_t mfmsrValue ;
__asm__( "mfmsr %0" : "=r" (mfmsrValue ) );
OUTPUT_PORT = mfmsrValue ;
If you want to avoid avoid adding an S-function, you can also add a Data Store Memory Block in your model, call it as mfmsrValue, with DataType uint32 and Storage class: Volatile. Declaring as volatile, for most Simulink Versions it will declare the variable in the code as the name you typed in the Data Store Memory: mfmsrValue.
After that, in a System Outputs block from Simulink Coder library, you can insert the following code which will read the MSR refisters and store the value in the decalred variable:
__asm__( "mfmsr %0" : "=r" (mfmsrValue ) );
If you make sure that the following blocks will be called exactly in this order (System Outputs first, followed by mfmsrValue Read) you will have the value from the desired register in the Data Store Memory.
Hope this helps,
Marius
Hello rafael.barbosa@chassisbrakes.com,
Our Read Registers Block provides access only to peripherals registers. The register you want to read is critical and is one of the process control registers in the PowerPC architecture.
However, this register may be read using the mfmsr assembly instruction. For this, you need to insert some custom code.
One way is to create your own S-Function to return the mfmsrValue variable.
volatile uint32_t mfmsrValue ;
__asm__( "mfmsr %0" : "=r" (mfmsrValue ) );
OUTPUT_PORT = mfmsrValue ;
If you want to avoid avoid adding an S-function, you can also add a Data Store Memory Block in your model, call it as mfmsrValue, with DataType uint32 and Storage class: Volatile. Declaring as volatile, for most Simulink Versions it will declare the variable in the code as the name you typed in the Data Store Memory: mfmsrValue.
After that, in a System Outputs block from Simulink Coder library, you can insert the following code which will read the MSR refisters and store the value in the decalred variable:
__asm__( "mfmsr %0" : "=r" (mfmsrValue ) );
If you make sure that the following blocks will be called exactly in this order (System Outputs first, followed by mfmsrValue Read) you will have the value from the desired register in the Data Store Memory.
Hope this helps,
Marius
Hello Marius,
Thank you for the response.
I tried to implement using the Data Store Memory Block approach and it works good.
Regards, Rafael