構造体のメンバに数値を代入しようしたのですが、
エラー(Invalid memory reference)が出てしまします。
なぜでしょうか?
c言語
1#include <iostream> 2#include <stdint.h> 3 4using namespace std; 5 int main(void){ 6 // Your code here! 7 #define __IO volatile /*!< Defines 'read / write' permissions */ 8 9 typedef struct 10 { 11 __IO uint32_t CR ; /*!< RCC clock control register, Address offset: 0x00 */ 12 __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x04 */ 13 __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x08 */ 14 __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x0C */ 15 __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x10 */ 16 __IO uint32_t AHBENR; /*!< RCC AHB peripheral clock register, Address offset: 0x14 */ 17 __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x18 */ 18 __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x1C */ 19 __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x20 */ 20 __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x24 */ 21 __IO uint32_t AHBRSTR; /*!< RCC AHB peripheral reset register, Address offset: 0x28 */ 22 __IO uint32_t CFGR2; /*!< RCC clock configuration register 2, Address offset: 0x2C */ 23 __IO uint32_t CFGR3; /*!< RCC clock configuration register 3, Address offset: 0x30 */ 24 __IO uint32_t CR2; /*!< RCC clock control register 2, Address offset: 0x34 */ 25 } RCC_TypeDef; 26 27 #define PI (uint32_t)0x40000000 28 #define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */ 29 #define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000) 30 #define RCC_BASE (AHBPERIPH_BASE + 0x00001000) 31 32 #define RCC ((RCC_TypeDef *) RCC_BASE) 33 34 RCC->CR = (uint32_t)0x0C; <--エラー発生(Invalid memory reference) 35}
回答2件
あなたの回答
tips
プレビュー