External SRAM on K20 Flexbus with MQX

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

External SRAM on K20 Flexbus with MQX

1,801 次查看
primozrebec
Contributor III

Hi all,

we have a 1 MB of external SRAM organized as 512K * 16 bit that is connected to K20 MCU flexbus. Read from SRAM is always 16 bit (both bytes) but we DO NOT have FB_AD0 pin connected to SRAM address line 0. So only even addresses should be accessed.

We want to have another MQX memory pool in order to store larger amount of data (various data structures). I've sccessfuly created new memory pool and allocated space from it, just as it is described here: https://community.freescale.com/message/329322#329322

We are having an issue with byte access to external SRAM e.g. when writing values to byte array. In this case, writing to odd addresses overwrites values in even addresses. Writing word and integer values aren't problematic. How should i employ aligned SRAM access? Is there a way to modify linker script (we are using GCC)?

Best,

Primoz

0 项奖励
回复
5 回复数

1,327 次查看
drqubit
Contributor II

Hello Primoz Rebec.

I think is not an alingment problem. In 32 bit environment, your pointers shall be aligned.

I think your problem is with pointer arithmetics. If you have a byte array located at 0x60000000 by example and access array[1] or array+1, your address will be truncated cause your missing FB_AD0. If you use memcpy, accessing even pointers, your data should be copied right. By definition, if you access odd addresses in a word aligned memory, your access will fail. You can check it trying to write to an odd address in pflash.

If you need to write to an odd byte only, you shall implement a custom access driver. Read 2 bytes from prior even address, modify 1 byte and write word back again.

Regads

0 项奖励
回复

1,327 次查看
primozrebec
Contributor III

Hello Ivan,

thank you for you input on this. In fact, i already have a custom external SRAM access driver to read/write 16-bit data. But now i want to make this functionality transparent for the application SW developer. We have a complex SW architecture, which uses many data structures. Memory for structure instances is all dynamically allocated. Pointers to those structures are passed to lower layers (including low-level drivers). With this design it is now impossible to control memory addresses which are accessed and we don't want to do complete rework. Is there a way to resolve this issue?

Best,

Primoz

0 项奖励
回复

1,327 次查看
drqubit
Contributor II

I fear you can directly access any odd address without FB_AD0. If your external SRAM don't have byte address, you can solve it using an intermediate cache memory.

Best regards.

0 项奖励
回复

1,327 次查看
primozrebec
Contributor III

OK, i managed to:

- change a linker file, i added external SRAM region to linker file

- change my application, i defined a static byte array this memry region using "__attribute__ ... " keyword

I am able to access this array but i still have problems writing byte values to it, because writing to odd addresses re-write complete word value in external SRAM.

I dont see any possibility to setup address manipulaton in Flexbus core... Is there a way to resolve this issue?

Best,

Primoz

0 项奖励
回复

1,327 次查看
soledad
NXP Employee
NXP Employee

Hello Primoz Rebec,

Please check the below application note (pages 17,18) and let me know if this helps.

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复