質問編集履歴
3
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
構造体のメンバに数値を代入しようしたのですが、
|
2
2
|
|
3
|
-
エラー(
|
3
|
+
エラー(Invalid memory reference)が出てしまします。
|
4
4
|
|
5
5
|
なぜでしょうか?
|
6
6
|
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
-
RCC->CR = (uint32_t)0x0C;
|
77
|
+
RCC->CR = (uint32_t)0x0C; <--エラー発生(Invalid memory reference)
|
78
78
|
|
79
79
|
}
|
80
80
|
|
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
構造体のメンバに数値を代入しようしたのですが、
|
2
2
|
|
3
|
-
エラー(
|
3
|
+
エラー(:Invalid memory reference)が出てしまします。
|
4
4
|
|
5
5
|
なぜでしょうか?
|
6
6
|
|
@@ -8,66 +8,74 @@
|
|
8
8
|
|
9
9
|
```c言語
|
10
10
|
|
11
|
-
|
11
|
+
#include <iostream>
|
12
12
|
|
13
|
-
|
13
|
+
#include <stdint.h>
|
14
14
|
|
15
|
-
3 #define __IO volatile /*!< Defines 'read / write' permissions */
|
16
15
|
|
17
|
-
4
|
18
16
|
|
19
|
-
|
17
|
+
using namespace std;
|
20
18
|
|
21
|
-
|
19
|
+
int main(void){
|
22
20
|
|
23
|
-
|
21
|
+
// Your code here!
|
24
22
|
|
25
|
-
|
23
|
+
#define __IO volatile /*!< Defines 'read / write' permissions */
|
26
24
|
|
27
|
-
|
25
|
+
|
28
26
|
|
29
|
-
|
27
|
+
typedef struct
|
30
28
|
|
31
|
-
|
29
|
+
{
|
32
30
|
|
33
|
-
|
31
|
+
__IO uint32_t CR ; /*!< RCC clock control register, Address offset: 0x00 */
|
34
32
|
|
35
|
-
|
33
|
+
__IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x04 */
|
36
34
|
|
37
|
-
|
35
|
+
__IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x08 */
|
38
36
|
|
39
|
-
|
37
|
+
__IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x0C */
|
40
38
|
|
41
|
-
|
39
|
+
__IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x10 */
|
42
40
|
|
43
|
-
|
41
|
+
__IO uint32_t AHBENR; /*!< RCC AHB peripheral clock register, Address offset: 0x14 */
|
44
42
|
|
45
|
-
|
43
|
+
__IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x18 */
|
46
44
|
|
47
|
-
|
45
|
+
__IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x1C */
|
48
46
|
|
49
|
-
|
47
|
+
__IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x20 */
|
50
48
|
|
51
|
-
2
|
49
|
+
__IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x24 */
|
52
50
|
|
53
|
-
22
|
51
|
+
__IO uint32_t AHBRSTR; /*!< RCC AHB peripheral reset register, Address offset: 0x28 */
|
54
52
|
|
55
|
-
|
53
|
+
__IO uint32_t CFGR2; /*!< RCC clock configuration register 2, Address offset: 0x2C */
|
56
54
|
|
57
|
-
|
55
|
+
__IO uint32_t CFGR3; /*!< RCC clock configuration register 3, Address offset: 0x30 */
|
58
56
|
|
59
|
-
2
|
57
|
+
__IO uint32_t CR2; /*!< RCC clock control register 2, Address offset: 0x34 */
|
60
58
|
|
61
|
-
|
59
|
+
} RCC_TypeDef;
|
62
60
|
|
63
|
-
27
|
64
61
|
|
65
|
-
28 #define RCC ((RCC_TypeDef *) RCC_BASE)
|
66
62
|
|
67
|
-
2
|
63
|
+
#define PI (uint32_t)0x40000000
|
68
64
|
|
69
|
-
|
65
|
+
#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */
|
70
66
|
|
67
|
+
#define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000)
|
68
|
+
|
69
|
+
#define RCC_BASE (AHBPERIPH_BASE + 0x00001000)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
#define RCC ((RCC_TypeDef *) RCC_BASE)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
RCC->CR = (uint32_t)0x0C;
|
78
|
+
|
71
|
-
|
79
|
+
}
|
72
80
|
|
73
81
|
```
|
1
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
なぜでしょうか?
|
6
6
|
|
7
7
|
|
8
|
+
|
9
|
+
```c言語
|
8
10
|
|
9
11
|
1 int main(void){
|
10
12
|
|
@@ -67,3 +69,5 @@
|
|
67
69
|
30 RCC->CR = (uint32_t)0x0C; <--エラー発生(Invalid memory reference)
|
68
70
|
|
69
71
|
31}
|
72
|
+
|
73
|
+
```
|