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