2014-11-13 04:32 AM
Hi everybody,
I'm a beginner with STM32F30x µP. I'd like to made a DMA transfers from SRAM to an external DAC via SPI communication. Is it possible? Can I even configure a timer (TIMx) to generate a PWM signal or One Pulse Mode signal on TIMx_CHx and use it as DMA trigger and also as NSS signal input to latch the SPI data transfers to my external DAC? Thanks for your advice on that point. Regards, Franck2014-11-19 02:48 PM
Hi Linas,
Many thanks for the post. Franck2014-11-20 01:15 PM
Hi Guys,
While looking for some programs example on the forum, i found the following [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20SPI%20DMA%20for%20External%20SPI%20DAC&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=550]link which is more or less what i'm looking for; i.e to stream 16-bit or even 32-bit word data to an external DAC, with no sweat for the processor and doing so by timer triggered DMA transfers to SPI as a viable option. I'm coding and will share with everybody asap. Best regards, Franck2014-11-26 02:17 AM
Hi everybody,
As suggested by Jan, I divide the problem in three part: first, learn to set up the timer, then leran to set up SPI with ''manual'' ''filling'' of data register, and then learn to set up the DMA.'' The first part is completed as I am able to set two Timer in PWM mode. (See attachment). Now configuring the SPI I have many questions: 1- Should I define the NSS, SCK,MISO, MOSI pins as follow: /* GPIOA, GPIOB & GPIOC Clocks enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB |RCC_AHBPeriph_GPIOC, ENABLE); /********************************************SPI Configuration*************************************/ /*Configuration pins used by SP2: * SPI2_NSS = PB12 * SPI2_SCK = PB13 * SPI2_MISO = PB14 //for FULL DUPLEX; Will not be used in our case? * SPI2_MOSI = PB15 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_PinAFConfig(GPIOB, GPIO_PinSource12, GPIO_AF_5); //NSS PB12 AF5 GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_5); //SCK PB13 AF5 GPIO_PinAFConfig(GPIOB, GPIO_PinSource14, GPIO_AF_5); //MISO PB14 AF5 GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_5); //MOSI PB15 AF5 2- Knowing that I'll be in simplex mode ( The SPI will only transmit data => RXONLY=0 of SPI2_CR2 register), and that I want a DMA TIM triggered on SPI, should I used the DMA Tx? I'm getting confused on that point. The rerence Manual says on that point: ''When starting communication using DMA...these steps must be followed in order: * Enable DMA Rx buffer....not my case as DMA_Rx is unused in my case *Enable DMA streams for Tx and Rx in DMA registers, if the streams are used (Yes) *Enable DMA Tx buffer in the TXDMAEN bit in the SPI_CR2 register, if DMA_Tx is used *Enable the SPI by setting the SPE bit. 3- So, as in my case it is the DMA which is triggered by a timer and send datas taken in SRAM to SPI should i define the SPI as usual in a normal way enabeling the clock, the mode, data size, clock phase and polarity controls,data frame format...... Thanks for your feedback on that points. Franck2014-11-26 02:19 AM
Attachment
________________ Attachments : Screen_2014-11-21_09-35-54.jpeg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I14T&d=%2Fa%2F0X0000000bkb%2FMTUAjTQVE8m4ZAH88cur3q38QAc99qkTCdz40H4xS6U&asPdf=false2014-11-26 06:50 AM
2014-11-27 09:38 AM
2014-11-27 09:56 AM
2014-11-28 05:51 AM
Any Help?
I'm stuck.... Thanks2014-11-28 06:27 AM
i've add a buffer:
uint16_t TxBuffer[32] = { 0xAAAA, 0xAAAB, 0xAAAC, 0xAAAD, 0xAAAE, 0xAAAF, 0xAAB0, 0xAAB1, 0xAAB2, 0xAAB3, 0xAAB4, 0xAAB5, 0xAAB6, 0xAAB7, 0xAAB8, 0xAAB9, 0xAABA, 0xAABB, 0xAABC, 0xAABD, 0xAABE, 0xAABF, 0xAAC0, 0xAAC1, 0xAAC2, 0xAAC3, 0xAAC4, 0xAAC5, 0xAAC6, 0xAAC7, 0xAAC8, 0xAAC9}; uint16_t TTxBuffer[32]; I manage it: int main(void) { uint8_t Idx = 0; /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f30x.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f30x.c file */ /* Fill TTxBuffer table */ for (Idx = 0; Idx <32; Idx++) { TTxBuffer[Idx] = TxBuffer[Idx] ; } In debug mode looking at the SPI2 the SPI2 data Register is empty. I don't understand why? Thanks for your help2014-12-15 01:39 AM
See solution [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Is%20there%20anaybody%20that%20have%20a%20TIM%20triggered%20DMA%20working%20Code&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=110]here