Data Serialization

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

Data Serialization

1,138 Views
yashkumar
Contributor III

Hi,

I am working on data serialization with S32K142/144 micro controller . I am using this  controller for CAN specific applications. And in which i realized "data serialization " should restrictively followed .

So,i have gone thorough alot-off  posts and documentations.

after all i have still one doubt , as for any peripheral resister access , we should follow "read after write".

As in below example, during accessing of LPTMR0_CSR.

void lptmr_isr(void)

{

  // Declare dummy variable to store the read of the LPTMR0_CSR register

volatile int dummy_var

/****   STEP #1  ****/

  // Clear the flag; enable interrupts; enable the timer

  LPTMR0_CSR = ( LPTMR_CSR_TEN_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TCF_MASK  );

  /****  STEP #2  ****/

   // Store CSR register in dummy_var to serialize the clearing of the TCF flag

  dummy_var = LPTMR0_CSR;

}

But,

1. can we use just memory barrier instruction __asm("dsb"); in place of "dummy_var = LPTMR0_CSR;" instruction ?

2. Is could you please give few example of real time use of  __asm("dmb"); __asm("dsb"); __asm("isb"); .

Please help me on this.

Thankyou!

Labels (1)
1 Reply

895 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
I had to modify this comment.
DSB instruction serialize all explicit memory accesses.
But it doesn’t serialize peripheral writes, in this case, we need to do Read-After-Write sequence to be sure the writes are complete before we can proceed with execution of subsequent instructions. We can use ISB instruction to flush the pipeline if needed.

Regards,
Daniel