`uint16_t buf[6] attribute((at(0xd0000000))) = {0}; //将缓冲数组分配到外部dram中。
void TestDram(void)
{
uint16_t xxx[6] = {0x1111,0x2222,0x3333,0x4444,0x5555,0x6666};
for(int i = 0; i < 5;i++)
{
buf[i] = xxx[i];
}
for(int i = 0; i < 5; i++)
{
if (xxx[i] != buf[i])
{
USART_SendByte((unsigned char*)("error"),5);
}
else
{
USART_SendByte((unsigned char*)("ok"),2);
}
}
}
`
keil环境,使用默认编译器5.然后这样写一个数组,用buf[i]访问就会进入总线错误,但是用p = (char)0xd0000000;然后(p+i)访问就不会产生总线错误。不太懂是啥原理?mpu保护,编译器本身bug,但这样做就对了,折腾了一天。。。。。
标签:int,xxx,char,dram,编译器,stm32f767,buf,fmc From: https://www.cnblogs.com/LuRenZ1002/p/18068044