moo
/
bit-band
bit-band test
Fork of bit-band by
main.cpp@0:cd40794dcbe8, 2014-06-02 (annotated)
- Committer:
- moo
- Date:
- Mon Jun 02 02:28:30 2014 +0000
- Revision:
- 0:cd40794dcbe8
- Child:
- 1:95cec43280f9
bit-band test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moo | 0:cd40794dcbe8 | 1 | #include "mbed.h" |
moo | 0:cd40794dcbe8 | 2 | |
moo | 0:cd40794dcbe8 | 3 | DigitalOut led1(LED1); |
moo | 0:cd40794dcbe8 | 4 | |
moo | 0:cd40794dcbe8 | 5 | extern "C" void HardFault_Handler() {__nop();} |
moo | 0:cd40794dcbe8 | 6 | |
moo | 0:cd40794dcbe8 | 7 | int main() |
moo | 0:cd40794dcbe8 | 8 | { |
moo | 0:cd40794dcbe8 | 9 | volatile uint8_t *a1 = (uint8_t*)(0x10000000); // SRAM先頭アドレス |
moo | 0:cd40794dcbe8 | 10 | *a1 = (uint8_t)0x1; // Memory windowsにて0x1になることを確認 |
moo | 0:cd40794dcbe8 | 11 | |
moo | 0:cd40794dcbe8 | 12 | volatile uint8_t *a2 = (uint8_t*)(0x22000000); // SRAM先頭アドレスをbit-bandで指定 |
moo | 0:cd40794dcbe8 | 13 | *a2 = (uint8_t)0x0; // Memory windowsにて0x01になることを確認出来ない |
moo | 0:cd40794dcbe8 | 14 | |
moo | 0:cd40794dcbe8 | 15 | led1 = *a1; // この行を実行するとHardFault_Handler()が実行される |
moo | 0:cd40794dcbe8 | 16 | while (1); |
moo | 0:cd40794dcbe8 | 17 | } |