1.代码修改(可能)
wm_gpio_afsel.c里的添加或者修改psram config函数(关注一下是否一致):
void wm_psram_config(uint8_t numsel)
{
switch(numsel)
{
case 0:
tls_io_cfg_set(WM_IO_PB_00, WM_IO_OPTION4);/*CK*/
tls_io_cfg_set(WM_IO_PB_01, WM_IO_OPTION4);/*CS*/
tls_io_cfg_set(WM_IO_PB_02, WM_IO_OPTION4);/*D0*/
tls_io_cfg_set(WM_IO_PB_03, WM_IO_OPTION4);/*D1*/
tls_io_cfg_set(WM_IO_PB_04, WM_IO_OPTION4);/*D2*/
tls_io_cfg_set(WM_IO_PB_05, WM_IO_OPTION4);/*D3*/
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_PSRAM);
break;
case 1:
tls_io_cfg_set(WM_IO_PA_15, WM_IO_OPTION1);/*CK*/
tls_io_cfg_set(WM_IO_PB_27, WM_IO_OPTION1);/*CS*/
tls_io_cfg_set(WM_IO_PB_02, WM_IO_OPTION1);/*D0*/
tls_io_cfg_set(WM_IO_PB_03, WM_IO_OPTION1);/*D1*/
tls_io_cfg_set(WM_IO_PB_04, WM_IO_OPTION1);/*D2*/
tls_io_cfg_set(WM_IO_PB_05, WM_IO_OPTION1);/*D3*/
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_PSRAM);
break;
case 2: //w861
tls_io_cfg_set(WM_IO_PA_15, WM_IO_OPTION1);/*CK*/
tls_io_cfg_set(WM_IO_PB_27, WM_IO_OPTION1);/*CS*/
tls_io_cfg_set(WM_IO_PB_28, WM_IO_OPTION1);/*D0*/
tls_io_cfg_set(WM_IO_PB_29, WM_IO_OPTION1);/*D1*/
tls_io_cfg_set(WM_IO_PB_30, WM_IO_OPTION1);/*D2*/
tls_io_cfg_set(WM_IO_PB_31, WM_IO_OPTION1);/*D3*/
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_PSRAM);
break;
default:
TLS_DBGPRT_ERR("psram afsel config error!");
break;
}
}
2.PSRAM的初始化
wm_main.c启动后初始化一下PSRAM(建议放到函数wm_gpio_config):
wm_psram_config(0);//实际使用的psram管脚选择0或者1,W861为2
//初始化psram
psram_init(1);
3.使用
因为内置的内存和psram的内存不连续,可以参考heap_dram.c[文章末尾附件]的实现来单独管理这块内存。
这个文件里只需要关注两个宏的修改,因为PSRAM起始地址0x30000000,只需要修改实际的PSRAM容量(DRAM_HEAP_SIZE)即可。
/* Heap should align to DRAM_HEAP_ALIGNMENT */
#define DRAM_HEAP_BASE (0x30000000)
/* Size should be smaller than ~DRAM_HEAP_MAGIC */
#define DRAM_HEAP_SIZE (2*1024 * 1024)
附件:heap_dram.zip
话说,可以组合使用吗?譬如说PA15作为CK, 然后使用PB1-PB5作为CS, DAT0~DAT3。我个人觉得复用功能,应该是所有引脚中,有该功能的GPIO都能用于复用吧?
@haoronMango 理论上是可以的。
请问怎么赋值psram中的内容,可以直接使用指针吗?
// 下面这样用可以吗?
void my_psram_test()
{
}
@haoronMango 你成功了吗?我这样用好像失败了
psram型号可以推荐一下吗
Hello! What am I doing wrong?
Result:
Chip PS6404L-3SQR-SN
This chip works correctly on Air103
@AnatolSher w80x_psram_demo.zip
Thank you isme! I will try to resolder the chip to "0" configuration.
But it is strange... Is pin multiplexing doesn't work well?
@AnatolSher "0" configuration is ok