This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我通过DMA方式访问flash读写数据,采用中断的方式可以读写,当采用dma方式,没反应,附代码,
void UCSI_SPIB0_Init(void)
{
P2SEL |= BIT1+BIT2+BIT3; //select B0 is SPI interface
P2DIR |= BIT0;
P5DIR |= BIT6; //close write protect
P5OUT |= BIT6;
UCB0CTL1 |= UCSWRST; //software reset
//2 edge,polarity is high,MSB,8bit,master mode,
UCB0CTL0 |= UCCKPL+UCMSB+UCMST+UCMODE_0+UCSYNC;
UCB0CTL1 |= UCSSEL_2;
UCB0BR0 |= 0x04;
UCB0CTL1 &=~UCSWRST;
P2OUT &=~BIT0; //打开片选
P5OUT |= BIT6; //关闭写保护
}
void SPI_B0_DMA_Config(void)
{
//DMA0 is spi_flash Tx
DMACTL0 |= DMA1TSEL_18 + DMA0TSEL_0; //触发源选择DMA channel 0 transfer select 0: USCIB0 transmit
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) SPI_S_buf); //SRC地址指针
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCB0TXBUF); //DST地址指针SPI_D_buf
DMA0SZ = 4;
DMA0CTL |= DMADT_1 + DMASRCINCR_3 + DMASBDB + DMAEN + DMALEVEL; //Single transfer, inc src, byte, enable
//DMADSTINCR_3+
//DAM1 is spi_flash_Rx
__data16_write_addr((unsigned short) &DMA1SA,(unsigned long) &UCB0RXBUF);//SPI_S_buf
__data16_write_addr((unsigned short) &DMA1DA,(unsigned long) SPI_R_buf);
DMA1SZ = 5;
DMA1CTL |= DMADT_1 + DMADSTINCR_3 + DMASBDB + DMAEN ;//+ DMAIE + DMAIFG+ DMASRCINCR_3
}
void DMA_Triggle(void)
{
//DMA0CTL |= DMAEN;
//UCB0TXBUF = 0xAA;
//DMA1CTL |= DMAREQ;
DMA0CTL |= DMAREQ;
}
是哪里的问题 ,谢谢!