RE: DSP56F807 - Mutual exclusion using IPL 0 maskin g

Started by Johnson, Jerry October 30, 2002
My Assembly language code for turning interrupts off is typically like the following snippet:
  move SR,y0
  bfset #$0200,SR
  move a0,x:(R2)+
  move a1,x:(R2)
  move y0,SR
Where R2, a0, and a1 are setup before the move sr,y0 instruction.
-----Original Message-----
From: Aaron Needles []
Sent: Tuesday, October 29, 2002 5:05 PM
Subject: [motoroladsp] DSP56F807 - Mutual exclusion using IPL 0 masking

    I need a mutual exclusion mechanism that allows access to two
global variables as an atomic unit.  To prevent code within an ISR
from accessing one of the variables during this short period, I would
like to mask IPL 0 interrupts while I access the pair and then unmask
IPL 0 interrupts again when done.  I would also like to put this code
into a function that automatically determines if masking is already
in affect (SR bit $0200 is set) so that the IPL 0 mask in the SR can
be restored to its original state.  This would allow the function to
be called from inside or outside ISRs without the user keeping track
of IPL 0 masking.
    Is it possible to use a BFSET instruction to set the IPL 0 mask
bit in the SR and then test whether this bit was actually changed? 
This would then allow me to restore the mask after my "critical
section" of code.  So far I have not been suscessful in my attempts
to do this, so I am wondering if anyone has a mechanism like this
    I am using an up to date version of Metrowerks with the 56F807


Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

About this discussion group:

To Join:

To Post:

To Leave:


More Groups:

">Yahoo! Terms of Service.