bit-band test

Dependencies:   mbed

Fork of bit-band by vics66@...

Files at this revision

API Documentation at this revision

Comitter:
moo
Date:
Tue Jun 03 21:14:03 2014 +0000
Parent:
0:cd40794dcbe8
Commit message:
bit-band test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jun 02 02:28:30 2014 +0000
+++ b/main.cpp	Tue Jun 03 21:14:03 2014 +0000
@@ -1,17 +1,26 @@
+/*
+* bit-band test
+*/
+
 #include "mbed.h"
 
 DigitalOut  led1(LED1);
 
-extern "C" void HardFault_Handler() {__nop();}
+extern "C" void HardFault_Handler() 
+{
+    __nop();
+}
 
 int main() 
 {
-    volatile uint8_t *a1 = (uint8_t*)(0x10000000);  // SRAM先頭アドレス
-    *a1 = (uint8_t)0x1;     // Memory windowsにて0x1になることを確認
+    volatile int *a1 = (int*)(0x10000000);  // SRAM先頭アドレス
+    *a1 = 0x1;      // Memory windowにて0x1 → 0x0になることを確認した
+    *a1 = 0x0;
 
-    volatile uint8_t *a2 = (uint8_t*)(0x22000000);  // SRAM先頭アドレスをbit-bandで指定
-    *a2 = (uint8_t)0x0;     // Memory windowsにて0x01になることを確認出来ない
+    volatile int *a2 = (int*)(0x22000000);  // SRAM先頭アドレスをbit-band-aliasで指定
+    *a2 = 0x1;      // Memory windowにて0x10000000を見ても0x1になることを確認出来ない
 
-    led1 = *a1;     // この行を実行するとHardFault_Handler()が実行される
+    __nop();    // この行を実行するとHardFault_Handler()に飛ぶ
+    __nop();
     while (1);
-}
+}