void Flash_DmaWrite( uint16 *pFlashAddr, unsigned char * pSrcBuf, unsigned int Length ) {// Making sure a multiplum of 4 bytes is transferred.while(Length & 0x0003){Length++;}dmaConfig.SRCADDRH = ((unsigned short)pSrcBuf >> 8) & 0x00FF;dmaConfig.SRCADDRL = (unsigned short)pSrcBuf & 0x00FF;dmaConfig.DESTADDRH = ((unsigned short)&X_FWDATA >> 8) & 0x00FF;dmaConfig.DESTADDRL = (unsigned short)&X_FWDATA & 0x00FF;dmaConfig.VLEN= DMA_VLEN_USE_LEN;dmaConfig.LENH= (Length >> 8) & 0x00FF;dmaConfig.LENL= Length & 0x00FF;dmaConfig.WORDSIZE = DMA_WORDSIZE_BYTE;dmaConfig.TMODE= DMA_TMODE_SINGLE;dmaConfig.TRIG= DMA_TRIG_FLASH;dmaConfig.SRCINC= DMA_SRCINC_1;dmaConfig.DESTINC= DMA_DESTINC_0;dmaConfig.IRQMASK= DMA_IRQMASK_DISABLE;dmaConfig.M8= DMA_M8_USE_8_BITS;dmaConfig.PRIORITY = DMA_PRI_HIGH;/* The DMA configuration data structure may reside at any location in* unified memory space, and the address location is passed to the DMA* through DMA0CFGH:DMA0CFGL.*/DMA0CFGH = ((unsigned short)&dmaConfig >> 8) & 0x00FF;DMA0CFGL = (unsigned short)&dmaConfig & 0x00FF;/* Waiting for the flash controller to be ready */while (FCTL & FCTL_BUSY);/* Configuring the flash controller. Setings:* FWT: 0x11 (default setting, matches 13 MHz clock frequency).* FADDRH:FADDRL: point to the area in flash to write to - flashDataAddr.*/FWT = 0x11;FADDRH = (short)pFlashAddr >> 9;FADDRL = ((short)pFlashAddr >> 1) & ~0xFF00;/* Erase the page that will be written to. */Flash_StartErase();/* Wait for the erase operation to complete. */while (FCTL & FCTL_BUSY);/* Arm the DMA channel, so that a DMA trigger will initiate DMA writing. */DMAARM |= DMA_CHANNEL_0;// Arm DMA channel 0/* Enable flash write. Generates a DMA trigger. Must be aligned on a 2-byte* boundary and is therefor implemented in assembly.*/Flash_StartWrite();/* Wait for DMA transfer to complete. */while (!(DMAIRQ & DMAIRQ_DMAIF0));/* Wait until flash controller not busy. */while (FCTL & (FCTL_BUSY | FCTL_SWBSY));/* By now, the transfer is completed, so the transfer count is reached.* The DMA channel 0 interrupt flag is then set, so we clear it here.*/DMAIRQ &= ~DMAIRQ_DMAIF0; }
flash写不进数据,不知道是什么原因。
Nutcracker:
需要先分辨是硬件还是软件原因。用TI参考板试试,如果也不能就是软件原因。
clody chen:
回复 Nutcracker:
我用TI参考代码也不行
clody chen:
回复 Nutcracker:
我用TI参考代码试了,也写不进数据,
Viki Shi:
回复 clody chen:
请问所用开发板是TI的还是自己设计的?
clody chen:
回复 Viki Shi:
TI 的开发板
Viki Shi:
回复 clody chen:
TI的开发板,TI的代码,那只能考虑接口的问题了
xiaoming su:
回复 Viki Shi:
什么叫借口的问题,能具体点吗?