I had try to make a simple code to transmit data by mibSPI3 (in SPI mode) with DMA
but my code has show a clock only , without any data from MOSI.
and i can sent data by force data to DAT1 on mibSPI register...
which I think maybe I has wrong config mibSPI and DMA.
this my code to config mibSPI and DMA .
void dmaConfigCtrlPacket(void) { /* - configuring dma control packets */ g_dmaCTRLPKT_TX.SADD = (uint32)&spi_TX; /* source address */ g_dmaCTRLPKT_TX.DADD = (uint32)&(mibspiREG3->DAT1); /* destination address */ g_dmaCTRLPKT_TX.CHCTRL = 0; /* channel control */ g_dmaCTRLPKT_TX.FRCNT = 1; /* frame count */ g_dmaCTRLPKT_TX.ELCNT = adc_Length; /* element count */ g_dmaCTRLPKT_TX.ELDOFFSET = 4; /* element destination offset */ g_dmaCTRLPKT_TX.ELSOFFSET = 0; /* element destination offset */ g_dmaCTRLPKT_TX.FRDOFFSET = 0; /* frame destination offset */ g_dmaCTRLPKT_TX.FRSOFFSET = 0; /* frame destination offset */ g_dmaCTRLPKT_TX.PORTASGN = 4; g_dmaCTRLPKT_TX.RDSIZE = ACCESS_8_BIT; /* read size */ g_dmaCTRLPKT_TX.WRSIZE = ACCESS_8_BIT; /* write size */ g_dmaCTRLPKT_TX.TTYPE = FRAME_TRANSFER ; /* transfer type */ g_dmaCTRLPKT_TX.ADDMODERD = ADDR_INC1; /* address mode read */ g_dmaCTRLPKT_TX.ADDMODEWR = ADDR_OFFSET; /* address mode write */ g_dmaCTRLPKT_TX.AUTOINIT = AUTOINIT_ON; /* autoinit */ g_dmaCTRLPKT_RX.SADD = (uint32)&(mibspiREG3->BUF); /* source address */ g_dmaCTRLPKT_RX.DADD = (uint32)&spi_RX; /* destination address */ g_dmaCTRLPKT_RX.CHCTRL = 1; /* channel control */ g_dmaCTRLPKT_RX.FRCNT = 1; /* frame count */ g_dmaCTRLPKT_RX.ELCNT = adc_Length; /* element count */ g_dmaCTRLPKT_RX.ELDOFFSET = 0; /* element destination offset */ g_dmaCTRLPKT_RX.ELSOFFSET = 4; /* element destination offset */ g_dmaCTRLPKT_RX.FRDOFFSET = 0; /* frame destination offset */ g_dmaCTRLPKT_RX.FRSOFFSET = 0; /* frame destination offset */ g_dmaCTRLPKT_RX.PORTASGN = 4; g_dmaCTRLPKT_RX.RDSIZE = ACCESS_8_BIT; /* read size */ g_dmaCTRLPKT_RX.WRSIZE = ACCESS_8_BIT; /* write size */ g_dmaCTRLPKT_RX.TTYPE = FRAME_TRANSFER ; /* transfer type */ g_dmaCTRLPKT_RX.ADDMODERD = ADDR_OFFSET; /* address mode read */ g_dmaCTRLPKT_RX.ADDMODEWR = ADDR_INC1; /* address mode write */ g_dmaCTRLPKT_RX.AUTOINIT = AUTOINIT_ON; /* autoinit */ /* upto 32 control packets are supported. */ /* - setting dma control packets */ dmaSetCtrlPacket(DMA_CH0,g_dmaCTRLPKT_RX); dmaSetCtrlPacket(DMA_CH1,g_dmaCTRLPKT_TX); /* - setting the dma channel to trigger on h/w request */ dmaSetChEnable(DMA_CH0, DMA_HW); dmaSetChEnable(DMA_CH1, DMA_SW); }
and Thisi my main..
void main(void) { /* USER CODE BEGIN (3) */ i2cInit(); // Initial I2C spiInit(); // Initial SPI gioInit(); // Initial GPIO mibspiInit(); // Initial SPI1-3-5 for ADS1278 gioSetDirection(gioPORTA, 0xFF); gioSetBit(gioPORTA,0,1); spi_TX[0] = 0xAA; /* - creating a data chunk in system ram to start with ... */ // loadDataPattern(D_SIZE,&TX_DATA[0]); /* - enabling loopback ( this is to emulate data transfer without external wires */ // mibspiEnableInternalLoopback(mibspiREG1); dmaConfigCtrlPacket(); /* - assigning dma request: channel-0 with request line - 1 */ dmaReqAssign(0,1 ); /* - configuring the mibspi dma , channel 0 , tx line -0 , rxline -1 */ /* - refer to the device data sheet dma request source for mibspi tx/rx */ mibspiDmaConfig(mibspiREG3,0,0,1); /* - enabling dma module */ dmaEnable(); // spi_TX[0] = 0x80; while(1){ spi_TX[0] = 0x80; gioToggleBit(gioPORTA,0); /* - start the mibspi transfer tg 0 */ mibspiTransfer(mibspiREG3,0 ); /* ... wait until transfer complete */ while(!(mibspiIsTransferComplete(mibspiREG3,0))){ } /* copy from mibspi ram to sys ram */ mibspiGetData(mibspiREG3, 0, spi_RX); // i2cSetSlaveAdd(i2cREG1,0x40); // i2cSetStart(i2cREG1); // i2cSendByte(i2cREG1,0x42); // i2cSendByte(i2cREG1,0x21); // i2cSendByte(i2cREG1,0x36); delay(); } /* USER CODE END */ }
Have two thing I don't know what is it?
1. How I can make relate DMA data to mibSPI for transmit, I think that's wrong config.
2. what's channel control, that's has a limit to relate to any peripheral?
Thank You for your suggestion