ZHDA243 July 2026 AM13E23019 , AM13E232N9
这是正确引导 MCU 并开始使用外部 SDRAM 运行 AI 模型的主要功能序列。
int main(void)
{
/* Step 1: Hardware init — Device_Init() sets up clocks and cache.
* SYSCFG_DL_init() configures the EPI peripheral, making SDRAM
* accessible at 0x80000000. Both must run before any SDRAM access. */
Device_Init();
SYSCFG_DL_init();
/* Step 2: Copy .CS1_EXECUTE section from Flash to SDRAM.
* Transfers all AI model functions and weights from their Flash
* load addresses to their SDRAM run addresses (0x80000000+).
* After this call, all AI functions execute from SDRAM. */
memcpy(&sdram_code_runstart,&sdram_code_loadstart,(size_t)&sdram_code_loadsize);
/* Step 3: Call AI inference — PC moves to 0x80000000+ region.
* In the demo project this is executeFromCs0().
* For customer: replace with the AI model inference entry point. */
ExecuteFromSDRAM();/* customer replaces this with their AI inference call */
/*Verify dot product result. */
LOG_ASSERT((App_DotProd_Result == APP_DOT_PROD_EXPECTED),
"arm_dot_prod_f32 result mismatch: expected 20.0\r\n");
LOG("PASS: arm_dot_prod_f32 = %.1f — executed from SDRAM\r\n",
App_DotProd_Result);
LOG("Example PASS\r\n");
return 0;
}