硬件:EVM5515
IDE:CCS6.0
软件系统:DSP/BIOS
硬件使用了SDRAM和NorFlash;软件中配置了两个PRD,周期分别是10ms和1000ms。
SDRAM和NorFlash初始化代码如下:
SDRAM_init(); CSL_sdramPolledTest(); nor_flash_init(); // NorFlash初始化 // NorFlash读写测试===================================== // norflash_read(0x00000, (Uint16*)fs_win, 512); // norflash_read(0x40000, (Uint16*)fs_win, 512); // nor_flash_erase_Block4(); // norflash_read(0x40000, (Uint16*)fs_win, 512); // norflash_read(0x00000, (Uint16*)fs_win, 512); // norflash_write(0x40000, (Uint16*)fs_win, 512); // norflash_read(0x40000, (Uint16*)fs_win, 512);
SDRAM初始化函数参考了EVM5515官方例程CSL_EMIF_SDRAM_PollExample_Out。
CSL_Status SDRAM_init(void) { CSL_EmifHandlehEmif; CSL_EmifObjemifObj; CSL_SdramCfgsdramCfg; CSL_SdramTimrsdramTimr;CSL_SdramRowSizerowSize; CSL_Statusstatus; CSL_Statusresult; result = CSL_TEST_FAILED; hEmif= &emifObj; rowSize = CSL_SDRAM_ROW_ADDR_BITS_12; //printf("SDRAM Polled mode test\n\n"); /* Initialize Emif module */ status = EMIF_init(&emifObj); if(status != CSL_SOK) { //printf("EMIF SDRAM Init Failed!!\n"); return(result); } /* Assign values to sdram config structure */sdramCfg.NM= CSL_SDRAM_SDCR1_NM_DEFAULT; sdramCfg.CasLatency= CSL_SDRAM_SDCR1_CL_DEFAULT; sdramCfg.bit11to9Lock = CSL_SDRAM_SDCR1_BIT_11_9_LOCK_DEFAULT; sdramCfg.ibankPos= CSL_SDRAM_SDCR1_IBANK_DEFAULT; sdramCfg.ebank= CSL_SDRAM_SDCR1_EBANK_DEFAULT; sdramCfg.pageSize= CSL_SDRAM_SDCR1_PAGESIZE_DEFAULT; sdramCfg.selfRefresh = CSL_SDRAM_SDCR2_SR_DEFAULT; sdramCfg.pdMode= CSL_SDRAM_SDCR2_PD_DEFAULT; sdramCfg.pdwr= CSL_SDRAM_SDCR2_PDWR_DEFAULT; sdramCfg.pasr= CSL_SDRAM_SDCR2_PASR_DEFAULT; sdramCfg.rowSize= rowSize; sdramCfg.ibankPos= CSL_SDRAM_SDCR2_IBANK_POS_DEFAULT; sdramCfg.sdramDrive= CSL_SDRAM_SDCR2_SDRAM_DRIVE_DEFAULT; sdramCfg.bit9to1Lock = CSL_SDRAM_SDCR2_BIT_9_1_LOCK_DEFAULT;sdramTimr.tRAS= CSL_SDRAM_TRAS_VAL;sdramTimr.tRC= CSL_SDRAM_TRC_VAL; sdramTimr.tRRD= CSL_SDRAM_TRRD_VAL; sdramTimr.tRFC= CSL_SDRAM_TRFC_VAL; sdramTimr.tRP= CSL_SDRAM_TRP_VAL; sdramTimr.tRCD= CSL_SDRAM_TRCD_VAL; sdramTimr.tWR= CSL_SDRAM_TWR_VAL; sdramTimr.tXS= CSL_SDRAM_TXS_VAL;sdramTimr.refRate= CSL_SDRAM_REFRATE_VAL; /* Configure SDRAM settings */ status = SDRAM_config(hEmif, &sdramCfg, &sdramTimr); if(status != CSL_SOK) { //printf("EMIF SDRAM Config Failed!!\n"); return(result); } return(result); }
NorFlash初始化函数参考了EVM5515官方例程CSL_EMIF_NOR_CpuTransfer。
CSL_Status nor_flash_init(void) { CSL_Status status; status = CSL_SOK; hNor = &norObj; norCfg.asyncWaitCfg = &norAsyncWaitCfg; norCfg.asyncCfg = &norAsyncCfg; status = NOR_setup(&norObj, 0); if(CSL_SOK != status) { printf("SETUP: Bad Status\n"); } status = NOR_emifResetAndClock(hNor); if(CSL_SOK != status) { printf("NOR EMIF RST & CLK: Bad Status\n"); } /*norCfg was filled when it was defined*/ status = NOR_setupEmifChipSelect(hNor, &norCfg); if(CSL_SOK != status) { printf("SETUP EMIF CS: Bad Status\n"); } memset(hNor->deviceID, 0x0, sizeof(hNor->deviceID)); status = NOR_readId(hNor); if(CSL_SOK != status) { printf("READ ID: Bad Status\n"); } if((0xFF == hNor->deviceID[1]) || (0xFFFF == hNor->deviceID[1])) { printf("No Device Found\n"); } else { printf("Manufacturer ID %x\n", hNor->deviceID[0]); printf("Device ID %x\n", hNor->deviceID[1]); } memset(hNor->cfiData, 0x0, sizeof(hNor->cfiData)); status = NOR_readCFI(hNor); if(CSL_SOK != status) { printf("READ CFI: Bad Status\n"); } return status; }
问题:
没有添加nor_flash_init();函数时,程序运行正常,能够进入两个PRD函数;
添加nor_flash_init();函数后,无法进入RPD函数,在CCS中调试查看寄存器,全局中断已经使能,定时器中断已经使能。
为什么会这样?SDRAM和NorFlash使用有冲突吗?
Shide Lu:
将NorFlash测试代码取消屏蔽,如下:
SDRAM_init();CSL_sdramPolledTest();nor_flash_init(); // NorFlash初始化// NorFlash读写测试=====================================norflash_read(0x00000, (Uint16*)fs_win, 512);norflash_read(0x40000, (Uint16*)fs_win, 512);nor_flash_erase_Block4();norflash_read(0x40000, (Uint16*)fs_win, 512);norflash_read(0x00000, (Uint16*)fs_win, 512);norflash_write(0x40000, (Uint16*)fs_win, 512);norflash_read(0x40000, (Uint16*)fs_win, 512);读Block0的前512 words,擦除Block4,写入512字节,操作正常。
Shine:
SDRAM在CS0, norflash在CS2,不会互相冲突。
如果添加nor_flash_init();不添加PRD函数时,程序都能正常执行吗?
如果添加nor_flash_init();后,定时器中断是否产生了(IFR寄存器)?