调试的时候,不用DMA能正常发出波形,用了DMA就不能正常发送波形。请帮忙看下我的DMA的初始化可有问题
void spi_TFT_init(void)
{
spi_parameter_struct spi_init_struct;
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_GPIOB);
rcu_periph_clock_enable(RCU_SPI1);
/* enable DMA clock */
rcu_periph_clock_enable(RCU_DMA0);
rcu_periph_clock_enable(RCU_AF);
// /* SPI1_SCK(PB13), SPI1_RW(PB14) and SPI1_MOSI(PB15) GPIO pin configuration */
gpio_init(GPIOB, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_13 |GPIO_PIN_15);
/* TFT REST ANDE BACKLIGHT GPIO pin configuration */
gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_11|GPIO_PIN_12);
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_14);
/* SPI1_CS(Pb12) GPIO pin configuration */
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_12);
//
TFT_CS_HIGH();
dma_parameter_struct dma_init_struct;
/* SPI0 transmit dma config:DMA0-DMA_CH1 */
dma_deinit(DMA0, DMA_CH1);
dma_init_struct.periph_addr = (uint32_t)&SPI_DATA(SPI1);
dma_init_struct.memory_addr = (uint32_t)disbuff1;
dma_init_struct.direction = DMA_MEMORY_TO_PERIPHERAL;
dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT;
dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT;
dma_init_struct.priority = DMA_PRIORITY_HIGH;
dma_init_struct.number = 100;
dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
dma_init(DMA0, DMA_CH1, &dma_init_struct);
/* configure DMA mode */
dma_circulation_disable(DMA0, DMA_CH1);
dma_memory_to_memory_disable(DMA0, DMA_CH1);
// nvic_priority_group_set(NVIC_PRIGROUP_PRE1_SUB3);
nvic_irq_enable(DMA0_Channel1_IRQn,0,0);
/* enable DMA transfer complete interrupt */
dma_interrupt_enable(DMA0, DMA_CH1, DMA_INT_FTF|DMA_INT_ERR);
/* SPI0 parameter config */
spi_init_struct.trans_mode = SPI_TRANSMODE_BDTRANSMIT;
spi_init_struct.device_mode = SPI_MASTER;
spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT;;
spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE;
spi_init_struct.nss = SPI_NSS_SOFT;
spi_init_struct.prescale = SPI_PSC_4 ;
spi_init_struct.endian = SPI_ENDIAN_MSB;;
spi_init(SPI1, &spi_init_struct);
// spi_bidirectional_transfer_config(SPI1,SPI_BIDIRECTIONAL_TRANSMIT);
/* set crc polynomial */
//spi_crc_polynomial_set(SPI1,7);
/* enable SPI1 */
spi_enable(SPI1);
dma_channel_enable(DMA0, DMA_CH1);
spi_dma_enable(SPI1, SPI_DMA_TRANSMIT);
// dma_memory_address_config(DMA0,DMA_CH1,(uint32_t)(disbuff1));
// dma_transfer_number_config(DMA0,DMA_CH1,320);
// dma_channel_enable(DMA0, DMA_CH1);
}
|