Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of bit-band by
Revision 1:95cec43280f9, committed 2014-06-03
- 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 |
diff -r cd40794dcbe8 -r 95cec43280f9 main.cpp
--- 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);
-}
+}
