moo / Mbed 2 deprecated bit-band

Dependencies:   mbed

Fork of bit-band by vics66@...

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 * bit-band test
00003 */
00004 
00005 #include "mbed.h"
00006 
00007 DigitalOut  led1(LED1);
00008 
00009 extern "C" void HardFault_Handler() 
00010 {
00011     __nop();
00012 }
00013 
00014 int main() 
00015 {
00016     volatile int *a1 = (int*)(0x10000000);  // SRAM先頭アドレス
00017     *a1 = 0x1;      // Memory windowにて0x1 → 0x0になることを確認した
00018     *a1 = 0x0;
00019 
00020     volatile int *a2 = (int*)(0x22000000);  // SRAM先頭アドレスをbit-band-aliasで指定
00021     *a2 = 0x1;      // Memory windowにて0x10000000を見ても0x1になることを確認出来ない
00022 
00023     __nop();    // この行を実行するとHardFault_Handler()に飛ぶ
00024     __nop();
00025     while (1);
00026 }