icache problems in I.MX RT1021

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

icache problems in I.MX RT1021

跳至解决方案
1,411 次查看
nda
Contributor III

Hello. I've never used MPU and cache before, so i dont know how to solve problem. 

I'am working with LPSPI and receiving data form external flash: 

base->TCR |= LPSPI_TCR_TXMSK(isTxMask); // start transmission

while (!(base->SR & LPSPI_SR_FCF_MASK)) {}; // waiting for frame transfer has completed
this code doesnot work properly. Some times it works and some time it doesnot. It hangs and i cant even stop the debugger. If i disable icache before waiting it works, but delays are significant. 

This works:

base->TCR |= LPSPI_TCR_TXMSK(isTxMask);

if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR)){SCB_DisableICache();}
while (!(base->SR & LPSPI_SR_FCF_MASK)) {};
SCB_EnableICache();

Does anybody can explain me, what i am doing wrong?

标签 (1)
0 项奖励
回复
1 解答
1,396 次查看
nda
Contributor III

Thank you Crist for your answer.

Your advice does not help.  

I dont know why simple while loop does not work somtimes. Looking for another flag helped me:

while (!(base->SR & LPSPI_SR_RDF_MASK)) {};

 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,398 次查看
crist_xu
NXP Employee
NXP Employee

Hi, 

    I saw that you said: "If i disable icache before waiting it works, but delays are significant."  Does this mean if you add a delay loop,

also can fix your issue? if that, i think that you can test __DSB() __ISB() instead, without the SCB_DisableIcache();

 

Regards,

       Crist

0 项奖励
回复
1,397 次查看
nda
Contributor III

Thank you Crist for your answer.

Your advice does not help.  

I dont know why simple while loop does not work somtimes. Looking for another flag helped me:

while (!(base->SR & LPSPI_SR_RDF_MASK)) {};

 

0 项奖励
回复