How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P?

ソリューションへジャンプ
2,055件の閲覧回数
rafael_barbosa
Contributor IV

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?

pastedImage_1.png

Kind Regards, Rafael

1 解決策
1,941件の閲覧回数
mariuslucianand
NXP Employee
NXP Employee

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.

pastedImage_7.png

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.

pastedImage_10.png

Hope this helps,

Marius

元の投稿で解決策を見る

2 返答(返信)
1,942件の閲覧回数
mariuslucianand
NXP Employee
NXP Employee

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.

pastedImage_7.png

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.

pastedImage_10.png

Hope this helps,

Marius

1,941件の閲覧回数
rafael_barbosa
Contributor IV

Hello Marius,

Thank you for the response.

I tried to implement using the Data Store Memory Block approach and it works good.

Regards, Rafael