HAL Timer Triggered SPI Transfer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-27 8:02 AM
Posted on June 27, 2016 at 17:02
I am trying to transfer data to spi using timer 3 as a time base.
Timer 3 works fine. Than I am using : DMA1 Stream2 Channel5 to trigger memory to SPI2->DR transfers, with no joy.//TIMER 3 CHANNEL 4 UPDATE
hdma_tim3_ch4_up.Instance = DMA1_Stream2; hdma_tim3_ch4_up.Init.Channel = DMA_CHANNEL_5; hdma_tim3_ch4_up.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_tim3_ch4_up.Init.PeriphInc = DMA_PINC_DISABLE; hdma_tim3_ch4_up.Init.MemInc = DMA_MINC_DISABLE; hdma_tim3_ch4_up.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; hdma_tim3_ch4_up.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; hdma_tim3_ch4_up.Init.Mode = DMA_CIRCULAR; hdma_tim3_ch4_up.Init.Priority = DMA_PRIORITY_LOW; hdma_tim3_ch4_up.Init.FIFOMode = DMA_FIFOMODE_DISABLE; HAL_DMA_Init(&hdma_tim3_ch4_up); /* Several peripheral DMA handle pointers point to the same DMA handle. Be aware that there is only one stream to perform all the requested DMAs. */ __HAL_LINKDMA(htim_base,hdma[TIM_DMA_ID_CC4],hdma_tim3_ch4_up); __HAL_LINKDMA(htim_base,hdma[TIM_DMA_ID_UPDATE],hdma_tim3_ch4_up); /**MAIN.c*********************/ DMA_HandleTypeDef hdma_tim3_ch4_up; HAL_TIM_OC_Start(&htim3, TIM_CHANNEL_4); //start timer 4, works HAL_DMA_Start_IT(&hdma_tim3_ch4_up, (uint32_t*)&SV.fields.internal_current, (uint32_t*)(&(SPI2->DR)), 1);__HAL_TIM_ENABLE_DMA(&htim3, TIM_DMA_UPDATE); //TIM1 trigger DMA transfer
Still no data on the spi bus.
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-27 10:42 AM
Posted on June 27, 2016 at 19:42
__HAL_LINKDMA(htim_base,hdma[TIM_DMA_ID_CC4],hdma_tim3_ch4_up);
__HAL_LINKDMA(htim_base,hdma[TIM_DMA_ID_UPDATE],hdma_tim3_ch4_up);
Decide if you are using UPDATE or CC4 (CHANNEL 4) as the trigger, you get to pick ONE, then apply consistently
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-28 8:42 AM
Posted on June 28, 2016 at 17:42
Thanks Clive,
it works like a charm. The combination of PWM generation on CH1 and fine delay generation with the update event allows for /CS generation on the SPI Bus. FabioOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-01 3:09 PM
Posted on July 02, 2016 at 00:09
Hi Fabio,
I'm trying to control SPI writes using a timer as well. Can you post the complete working code?-Pat