cancel
Showing results for 
Search instead for 
Did you mean: 

Error: registers may not be the same -- strexb r3,r2,[r3]'

WJ1
Associate

Hi,

I am currently using the following microcontroller (STM32F100C8T6B) in my design. I am using the STM32CubeIDE and I trying to build the project, but I am getting the following compiler errors from the "core_cm3.c" file

Error: registers may not be the same -- strexb r3,r2,[r3]'

Error: registers may not be the same -- strexh r3,r2,[r3]'

Any help would be greatly appreciated

Thanks,

WJ

 

This is the version for core_cm2.c

/**************************************************************************//**

* @file core_cm3.c

* @brief CMSIS Cortex-M3 Core Peripheral Access Layer Source File

* @version V1.30

* @date 30. October 2009

*

* @note

* Copyright (C) 2009 ARM Limited. All rights reserved.

 

Below is where the error in the file

/**

* @brief STR Exclusive (8 bit)

*

* @param value value to store

* @param *addr address pointer

* @return successful / failed

*

* Exclusive STR command for 8 bit values

*/

uint32_t __STREXB(uint8_t value, uint8_t *addr)

{

uint32_t result=0;

// register uint32_t result asm ("r2");

__ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );

return(result);

}

/**

* @brief STR Exclusive (16 bit)

*

* @param value value to store

* @param *addr address pointer

* @return successful / failed

*

* Exclusive STR command for 16 bit values

*/

uint32_t __STREXH(uint16_t value, uint16_t *addr)

{

uint32_t result=0;

register uint32_t result asm ("r2");

__ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );

return(result);

}

 

 

4 REPLIES 4
TDK
Super User

> * @version V1.30

> * @date 30. October 2009

That's pretty old.

 

The latest version, or at least a recent one generated by CubeMX is:

* @version  V5.0.8
 * @date     04. June 2018
 

 with code:

/**
  \brief   STR Exclusive (16 bit)
  \details Executes a exclusive STR instruction for 16 bit values.
  \param [in]  value  Value to store
  \param [in]    ptr  Pointer to location
  \return          0  Function succeeded
  \return          1  Function failed
 */
__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
{
   uint32_t result;

   __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
   return(result);
}
If you feel a post has answered your question, please click "Accept as Solution".

Thank you for your reply, may I have a copy of 

@version  V5.0.8

Thanks,

WJ

Pavel A.
Super User
* @version V1.30
* @date 30. October 2009

Consider using updated GCC compiler and proper CMSIS files for STM32 (2019 or newer and without modifications). 

This stuff should be in file cmsis_gcc.h.

 

TDK
Super User

Generate new startup CMSIS files with STM32CubeMX and copy them from there. There's quite a few files which are dependent on each other being synchronized. For example, this function has moved from core_cm3.c to cmsis_gcc.h.

 
If you're only concerned about this function, copy/replace it with the code above.
If you feel a post has answered your question, please click "Accept as Solution".