moo
/
bit-band
bit-band test
Fork of bit-band by
main.cpp@1:95cec43280f9, 2014-06-03 (annotated)
- Committer:
- moo
- Date:
- Tue Jun 03 21:14:03 2014 +0000
- Revision:
- 1:95cec43280f9
- Parent:
- 0:cd40794dcbe8
bit-band test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moo | 1:95cec43280f9 | 1 | /* |
moo | 1:95cec43280f9 | 2 | * bit-band test |
moo | 1:95cec43280f9 | 3 | */ |
moo | 1:95cec43280f9 | 4 | |
moo | 0:cd40794dcbe8 | 5 | #include "mbed.h" |
moo | 0:cd40794dcbe8 | 6 | |
moo | 0:cd40794dcbe8 | 7 | DigitalOut led1(LED1); |
moo | 0:cd40794dcbe8 | 8 | |
moo | 1:95cec43280f9 | 9 | extern "C" void HardFault_Handler() |
moo | 1:95cec43280f9 | 10 | { |
moo | 1:95cec43280f9 | 11 | __nop(); |
moo | 1:95cec43280f9 | 12 | } |
moo | 0:cd40794dcbe8 | 13 | |
moo | 0:cd40794dcbe8 | 14 | int main() |
moo | 0:cd40794dcbe8 | 15 | { |
moo | 1:95cec43280f9 | 16 | volatile int *a1 = (int*)(0x10000000); // SRAM先頭アドレス |
moo | 1:95cec43280f9 | 17 | *a1 = 0x1; // Memory windowにて0x1 → 0x0になることを確認した |
moo | 1:95cec43280f9 | 18 | *a1 = 0x0; |
moo | 0:cd40794dcbe8 | 19 | |
moo | 1:95cec43280f9 | 20 | volatile int *a2 = (int*)(0x22000000); // SRAM先頭アドレスをbit-band-aliasで指定 |
moo | 1:95cec43280f9 | 21 | *a2 = 0x1; // Memory windowにて0x10000000を見ても0x1になることを確認出来ない |
moo | 0:cd40794dcbe8 | 22 | |
moo | 1:95cec43280f9 | 23 | __nop(); // この行を実行するとHardFault_Handler()に飛ぶ |
moo | 1:95cec43280f9 | 24 | __nop(); |
moo | 0:cd40794dcbe8 | 25 | while (1); |
moo | 1:95cec43280f9 | 26 | } |