data on pins changes when interrupt is used

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

data on pins changes when interrupt is used

494 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Tue Dec 18 22:06:45 MST 2012
I have code, which changes port pins by masking. ALso a timer interrupt on regular basis of 250us come & chnage pins of that port.

Problem is when both occur at same time, data on port gets corrupted.How to avoid this.


void change()
{
  ........statemets
 .............
 LPC_GPIO->MASK[1] = ~(0x00f0);            
 LPC_GPIO->MPIN[1] = 0xa0;        
 LPC_GPIO->MASK[1] = 0x00; 
 ..................
 .................
}

void interrupt_any()
{
 LPC_GPIO->MASK[1] = ~(0x000f);
 LPC_GPIO->MPIN[1] = 0x0a;        
 LPC_GPIO->MASK[1] = 0x00; 
}

0 Kudos
Reply
1 Reply

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Wed Dec 19 05:53:05 MST 2012
Sounds like you need to disable interrupts around the critical code.
Your code is not atomic so it needs to be protected.
0 Kudos
Reply