Comment 6 for bug 1738730

Revision history for this message
Murat Ursavas (murat-ursavas) wrote : Re: Simple OR'ed assignment breaks the code silently

Sure,

This is the most obvious failing line:

    NVM_SPI->CTRL = USART_CTRL_SYNC | USART_CTRL_MSBF;

NVM_SPI is defined in a header file like this:

    #define NVM_SPI USART1

USART1 is defined in a vendor library like this:

#define USART1 ((USART_TypeDef *) USART1_BASE) /**< USART1 base pointer */

USART1_BASE is defined in another file like this:

#define USART1_BASE (0x4000C400UL) /**< USART1 base address */

Here's the struct definition for USART_TypeDef:

typedef struct
{
  __IOM uint32_t CTRL; /**< Control Register */
  __IOM uint32_t FRAME; /**< USART Frame Format Register */
  __IOM uint32_t TRIGCTRL; /**< USART Trigger Control register */
  __IOM uint32_t CMD; /**< Command Register */
  __IM uint32_t STATUS; /**< USART Status Register */
  __IOM uint32_t CLKDIV; /**< Clock Control Register */
  __IM uint32_t RXDATAX; /**< RX Buffer Data Extended Register */
  __IM uint32_t RXDATA; /**< RX Buffer Data Register */
  __IM uint32_t RXDOUBLEX; /**< RX Buffer Double Data Extended Register */
  __IM uint32_t RXDOUBLE; /**< RX FIFO Double Data Register */
  __IM uint32_t RXDATAXP; /**< RX Buffer Data Extended Peek Register */
  __IM uint32_t RXDOUBLEXP; /**< RX Buffer Double Data Extended Peek Register */
  __IOM uint32_t TXDATAX; /**< TX Buffer Data Extended Register */
  __IOM uint32_t TXDATA; /**< TX Buffer Data Register */
  __IOM uint32_t TXDOUBLEX; /**< TX Buffer Double Data Extended Register */
  __IOM uint32_t TXDOUBLE; /**< TX Buffer Double Data Register */
  __IM uint32_t IF; /**< Interrupt Flag Register */
  __IOM uint32_t IFS; /**< Interrupt Flag Set Register */
  __IOM uint32_t IFC; /**< Interrupt Flag Clear Register */
  __IOM uint32_t IEN; /**< Interrupt Enable Register */
  __IOM uint32_t IRCTRL; /**< IrDA Control Register */
  __IOM uint32_t ROUTE; /**< I/O Routing Register */
  __IOM uint32_t INPUT; /**< USART Input Register */
  __IOM uint32_t I2SCTRL; /**< I2S Control Register */
} USART_TypeDef; /** @} */

And __IOM is defined as:

#define __IOM volatile

The C++ compiler options are:

-g3 -gdwarf-2 -mcpu=cortex-m3 -mthumb -std=c++1y '-DDEBUG=1' -O0 -pedantic -Wall -Wextra -c -fmessage-length=0 -fno-rtti -fno-exceptions -mno-sched-prolog -fno-builtin -fpack-struct -fshort-enums -ffunction-sections -fdata-sections

Note:I've removed folder inclusions and some simple preprocessor definitions to hide some sensitive data about our project. I'm sure they are not related.

Do you need anything else?