完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
已经可以分配
#if defined(RT_USING_MEMHEAP) && defined(RT_USING_MEMHEAP_AS_HEAP) rt_system_heap_init((void *) SDRAM_BANK_ADDR, (void *) STM32_SDRAM_END); rt_memheap_init(&system_heap, "sdram", (void *)SDRAM_BANK_ADDR, IS42S16400J_SIZE); #else rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END); #5567 但是还是会死机,是哪里操作不对吗 |
|
|
|
先在.s文件 里面添加FSMC_SRAM_Init()函数,实现外部SDRAM的初始化如下图: 然后在初始化的时候先调用 rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); 初始化内部SRAM,然后调用 rt_memheap_init(&system_heap,"sdram",(void *)0x68000000,0x100000); 将外部SDRAM挂载到heap_map里面。编译下载后,就可以用rt_malloc等接口了。 FSMC_SRAM_Init()如下: void FSMC_SRAM_Init(void) { /*-- GPIOs Configuration -----------------------------------------------------*/ /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ RCC->AHB1ENR |= 0x00000078; //PD0,1,4,5,8~15 100M AF OUT_PP UP //PE0,1,7~15 100M AF OUT_PP UP //PF0~5,12~15 100M AF OUT_PP UP //PG0~5,10 100M AF OUT_PP UP /* Connect PDx pins to FMC Alternate function */ GPIOD->AFR[0] = 0x00CC00CC; GPIOD->AFR[1] = 0xCCCCCCCC; /* Configure PDx pins in Alternate function mode */ GPIOD->MODER = 0xAAAA0A0A; /* Configure PDx pins speed to 100 MHz */ GPIOD->OSPEEDR = 0xFFFF0F0F; /* Configure PDx pins Output type to push-pull */ GPIOD->OTYPER = 0x00000000; /* pull-up for PDx pins */ GPIOD->PUPDR = 0x55550505; /* Connect PEx pins to FMC Alternate function */ GPIOE->AFR[0] = 0xC00000CC; GPIOE->AFR[1] = 0xCCCCCCCC; /* Configure PEx pins in Alternate function mode */ GPIOE->MODER = 0xAAAA800A; /* Configure PEx pins speed to 100 MHz */ GPIOE->OSPEEDR = 0xFFFFC00F; /* Configure PEx pins Output type to push-pull */ GPIOE->OTYPER = 0x00000000; /* pull-up for PEx pins */ GPIOE->PUPDR = 0x55554005; /* Connect PFx pins to FMC Alternate function */ GPIOF->AFR[0] = 0x00CCCCCC; GPIOF->AFR[1] = 0xCCCC0000; /* Configure PFx pins in Alternate function mode */ GPIOF->MODER = 0xAA000AAA; /* Configure PFx pins speed to 100 MHz */ GPIOF->OSPEEDR = 0xFF000FFF; /* Configure PFx pins Output type to push-pull */ GPIOF->OTYPER = 0x00000000; /* pull-up for PFx pins */ GPIOF->PUPDR = 0x55000555; /* Connect PGx pins to FMC Alternate function */ GPIOG->AFR[0] = 0x00CCCCCC; GPIOG->AFR[1] = 0x00000C00; /* Configure PGx pins in Alternate function mode */ GPIOG->MODER = 0x00200AAA; /* Configure PGx pins speed to 100 MHz */ GPIOG->OSPEEDR = 0x00300FFF; /* Configure PGx pins Output type to push-pull */ GPIOG->OTYPER = 0x00000000; /* pull-up for PGx pins */ GPIOG->PUPDR = 0x00100555; /*-- FMC/FSMC Configuration --------------------------------------------------*/ /* Enable the FMC/FSMC interface clock */ RCC->AHB3ENR |= 0x00000001; //寄存器清零 //bank1有NE1~4,每一个有一个BCR+TCR,所以总共八个寄存器。 //这里我们使用NE3 ,也就对应BTCR[4],[5]。 FSMC_Bank1->BTCR[4]=0X00000000; FSMC_Bank1->BTCR[5]=0X00000000; FSMC_Bank1E->BWTR[4]=0X00000000; //操作BCR寄存器 使用异步模式,模式A(读写共用一个时序寄存器) //BTCR[偶数]:BCR寄存器;BTCR[奇数]:BTR寄存器 FSMC_Bank1->BTCR[4]|=1<<12;//存储器写使能 FSMC_Bank1->BTCR[4]|=1<<4; //存储器数据宽度为16bit //操作BTR寄存器 (HCLK=168M, 1个HCLK=6ns FSMC_Bank1->BTCR[5]|=8<<8; //数据保持时间(DATAST)为9个HCLK 6*9=54ns FSMC_Bank1->BTCR[5]|=0<<4; //地址保持时间(ADDHLD)未用到 FSMC_Bank1->BTCR[5]|=0<<0; //地址建立时间(ADDSET)为0个HCLK 0ns //闪存写时序寄存器 FSMC_Bank1E->BWTR[4]=0x0FFFFFFF;//默认值 //使能BANK1区域3 FSMC_Bank1->BTCR[4]|=1<<0; } |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
AI模型部署边缘设备的奇妙之旅:如何在边缘端部署OpenCV
1591 浏览 0 评论
tms320280021 adc采样波形,为什么adc采样频率上来波形就不好了?
1112 浏览 0 评论
1557 浏览 0 评论
1402 浏览 0 评论
1044 浏览 0 评论
74641 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 23:52 , Processed in 0.609409 second(s), Total 74, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号