Keil

簡介

编译函数或变量到指定地址

  • 将函数加载到指定位置 示例将 main.c 中的 delay 函数指定到 0x08020000 地址,可以在 c 文件中函数的定义处指定 delay 函数。 void delay(void) __attribute__ ((section(".ARM.__at_0x08020000")));
  • 将数组加载到指定位置 int Temp[] __attribute__ ((section(".ARM.__at_0x08020000"))) = {0x1, 0x2};
  • 将变量加载到指定位置以 AT32F403AVGT7 为例: 示例可以直接将 c 代码修改如下: const int Temp __attribute__ ((section(".ARM.__at_0x08020000"))) = 10; // RO int Temp __attribute__ ((section(".ARM.__at_0x20000000"))) = 10; // RW

加入 C Source File

User 右鍵 > Manage Project Item > Add Files 記得要選要加入的 Group,加入 C 檔即可,H 檔不用加

1
2
3
4
5
I2c
|-inc
    |-Source.h
|-src
    |-Source.c

建議維持此資料夾結構