Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
YongseokJeon
Level 4
Level 4
Distributor - Changnam (South Korea)
50 replies posted 50 questions asked 25 replies posted

Hi All,

I'm using the PSoC4100SP with PSoc Creator 4.2.

I have to use the __LDREXW, __STREXW, __DMB.

I found these functions in cmsis.armcc.h, cmsis_hcc.h but I think the macro should be defined correctly.

Please let me know how to use it.

(Add)

Actually, I'm converting other mcu firmware to PSoC.

please refer to below.

int mxc_get_lock(uint32_t *lock, uint32_t value)

{

    do {

   

        // Return if the lock is taken by a different thread

        if (__LDREXW((volatile unsigned long *)lock) != 0) {

            return E_BUSY;

        }

       

        // Attempt to take the lock

    } while (__STREXW(value, (volatile unsigned long *)lock) != 0);

   

    // Do not start any other memory access until memory barrier is complete

    __DMB();

   

    return E_NO_ERROR;

}

Thanks and Regards,

YS

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi YS,

I believe you should be able to use __DMB(). Regarding the __LDREXW and __STREXW, both of these are unavailable for Cortex-M0 and Cortex-M0+ CPUs -

pastedImage_0.png

pastedImage_1.png

Please refer to the Intrinsic Functions documentation for further information.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
1 Reply
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi YS,

I believe you should be able to use __DMB(). Regarding the __LDREXW and __STREXW, both of these are unavailable for Cortex-M0 and Cortex-M0+ CPUs -

pastedImage_0.png

pastedImage_1.png

Please refer to the Intrinsic Functions documentation for further information.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes