I am sharing variables between Xgate and s12x and so trying to use the Xgate semaphore to prevent any possible overlapping data access to the shared variables. But I could able to set and clear the semaphore from s12x, but in Xgate am not getting the intended response.
Semaphore setting in Xgate:
if ( _ssem ( 0 ) )
{
....
....
_csem ( 0 ) ;
}
Semaphore setting in S12x:
do
{
_XGSEM . Word = 0x0100 | 0x01 ;
}
while ( ! ( _XGSEM . Bits . XGSEM_grp & 0x01 ) ) ; ( comes out of this while loop till _ssem/ -csem is called in Xgate and then code is stuck here till wdt resets)
.....
.....
_XGSEM . Word = 0x0100 ;
On watching the XGSEM register in debugger, I could see semaphore '0' getting set and reset by the s12x, and then it is always '0'. After the ssem/csem code, the s12x is not able to set the semaphore. Could you please let me know what I am missing.
Today, I provided an extended answer for a question related to an XGATE. The answer provides answer also to you:
Data sharing between S12x and Xgate
Best regards,
Ladislav