You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
835 B
C
41 lines
835 B
C
/*
|
|
* fault_test.c
|
|
*
|
|
* Created on: 2016/12/25
|
|
* Author: Armink
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
void fault_test_by_unalign(void) {
|
|
volatile int * SCB_CCR = (volatile int *) 0xE000ED14; // SCB->CCR
|
|
volatile int * p;
|
|
volatile int value;
|
|
|
|
*SCB_CCR |= (1 << 3); /* bit3: UNALIGN_TRP. */
|
|
|
|
p = (int *) 0x00;
|
|
value = *p;
|
|
printf("addr:0x%02X value:0x%08X\r\n", (int) p, value);
|
|
|
|
p = (int *) 0x04;
|
|
value = *p;
|
|
printf("addr:0x%02X value:0x%08X\r\n", (int) p, value);
|
|
|
|
p = (int *) 0x03;
|
|
value = *p;
|
|
printf("addr:0x%02X value:0x%08X\r\n", (int) p, value);
|
|
}
|
|
|
|
void fault_test_by_div0(void) {
|
|
volatile int * SCB_CCR = (volatile int *) 0xE000ED14; // SCB->CCR
|
|
int x, y, z;
|
|
|
|
*SCB_CCR |= (1 << 4); /* bit4: DIV_0_TRP. */
|
|
|
|
x = 10;
|
|
y = 0;
|
|
z = x / y;
|
|
printf("z:%d\n", z);
|
|
}
|