Im Atmel Studio mit einem SAM21 Cortex M0 läuft das Programm in einen
hardfault wenn ein Zugriff auf eine Variable stattfindet.
Die Deklaration von xy_lcd_cursorPosition ist problemlos:
1 | bla.c
|
2 | #include "bla.h"
|
3 |
|
4 | //uint8_t xy_lcd_cursorPosition __attribute__((aligned(4)))=0;
|
5 | //uint32_t xy_lcd_cursorPosition =0;
|
6 | //uint8_t xy_lcd_cursorPosition;
|
7 | uint8_t xy_lcd_cursorPosition=0;
|
8 |
|
9 | static const __packed uint8_t ssd1306_font6x8 [] =
|
10 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp
|
11 | 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // !
|
12 | ...bla
|
Sobald aber ein Schreib(!)zugriff statt findet, läuft das Programm
sofort beim Start in einen hardfault. Ohne Zugriff läuft das Programm:
1 | status_code xy_lcd_init()
|
2 | { xy_lcd_cursorPosition=0; //->HardFault
|
3 | //xy_lcd_cursorPosition=0; //läuft
|
Ein Breakpoint bei
1 | //startup_sam21.c
|
2 | __libc_init_array();
|
geht. Danach im Disassembler weiter ist mühsam und bringt keine
Erkenntnisse.
1 | __asm("BKPT #1\n") ; // Break into the debugger
|
R0 = 0x20000118
R1 = 0xfffffff9
R2 = 0x118
R3 = 0x9E9
R12 = 1
IPSRm = 3
APSR = 0x40000000
PSR = 0x40000003
AIRCR =0xfa050000
SCR = 0
CCR = 0x00000208
Übrigens, ein Breakpoint bei
1 | status_code xy_lcd_init()
|
2 | {
|
3 | -> xy_lcd_cursorPosition=0; //->HardFault
|
wird nicht angelaufen.
Hat jemand eine Idee?
Besten Dank.