LPC43xx external SRAM data write abnormal problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPC43xx external SRAM data write abnormal problem

跳至解决方案
1,329 次查看
CaptainTeemo
Contributor III

Hello, I have an external SRAM on the EMC of LPC4357FET256, the model is IS61WV5128EDBLL-10TLI.

I found a very strange problem when I finished writing the driver debugging.

As shown in the figure, I wrote a functional verification program. It is normal for external SRAM to write data sequentially, write data out of order, and directly fill data.

全填充.png

直接赋值.png

When using pointer operation in the program, if the address %64<32, changing the data of this address will also change the data of this address +32. If address %64>=32, changing the data of this address will also change the data of this address -32. This resulted in all the wrong data I wrote.

写入出错.png
I've checked my EMC configuration, data width, timing, trying to close the buffers, nothing solves the problem.
What I'm thinking is that if my EMC is misconfigured, it should also be wrong to write data directly through the address in the first place. There should also be problems with random writes to memory and sequential writes. So I wonder if this is a BUG of the LPC43xx microcontroller, or a BUG of the Keil MDK?
Does anyone have a similar situation and can provide some guidance? thank you

0 项奖励
回复
1 解答
1,313 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Captain,

Regarding your question, I think the code is incorrect.

for(unsigned int  i=0; i<num; i++)

{

volatile unsigned int Add=0x1c00_0000+i;

volatile unsigned char data=*(ptr+i);

__asm("NOP");

*(volatile uint32_t *)Add=data;

}

for the *(volatile uint32_t *)Add=data; because the Add address is uint_32 type, the Add address can be 0x1c00_0000; 0x1c00_0004; 0x1c00_0008; 0x1c00_000C; but it can not be 0x1c00_0001;0x1c00_0002; 0x1c00_0003, otherwise, unalignment error will happen.

You can use the code like:

uint32_t temp;

unsigned char c0,c1,c2,c3;

for(unsigned int  i=0; i<num/4; i+4)

{

volatile unsigned int Add=0x1c00_0000+i;

 c0=*(ptr+i);

c1=*(ptr+i+1);

c2=*(ptr+i+2);

c3=*(ptr+i+3);

temp=c3<<24|c2<<16|c1<<8|c0;

__asm("NOP");

*(volatile uint32_t *)Add=temp;

}

Pls have a try.

Hope it can help you

BR

XiangJun Rong

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,314 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Captain,

Regarding your question, I think the code is incorrect.

for(unsigned int  i=0; i<num; i++)

{

volatile unsigned int Add=0x1c00_0000+i;

volatile unsigned char data=*(ptr+i);

__asm("NOP");

*(volatile uint32_t *)Add=data;

}

for the *(volatile uint32_t *)Add=data; because the Add address is uint_32 type, the Add address can be 0x1c00_0000; 0x1c00_0004; 0x1c00_0008; 0x1c00_000C; but it can not be 0x1c00_0001;0x1c00_0002; 0x1c00_0003, otherwise, unalignment error will happen.

You can use the code like:

uint32_t temp;

unsigned char c0,c1,c2,c3;

for(unsigned int  i=0; i<num/4; i+4)

{

volatile unsigned int Add=0x1c00_0000+i;

 c0=*(ptr+i);

c1=*(ptr+i+1);

c2=*(ptr+i+2);

c3=*(ptr+i+3);

temp=c3<<24|c2<<16|c1<<8|c0;

__asm("NOP");

*(volatile uint32_t *)Add=temp;

}

Pls have a try.

Hope it can help you

BR

XiangJun Rong

 

0 项奖励
回复
1,310 次查看
CaptainTeemo
Contributor III
多谢,我已经找到问题了,是其他程序更改了CCU的配置导致EMC工作不正常,不是单片机和SRAM本身的问题。
我还以为英文论坛只能用英文写问题,还担心老外看不懂所以全英文,结果俩中国人用英语在这聊了一大段 非常感谢你的留言,祝工作顺利升职加薪
Thank you, I have found the problem. It is other programs that change the configuration of the CCU and cause the EMC to work abnormally, not the problem of the microcontroller and the SRAM itself.
0 项奖励
回复
1,306 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Captain,

XiangJun Rong

0 项奖励
回复