0

I have a problem with triggering NSS pin, when transmitting SPI with DMA. I use a CubeMX to generate whole core of project. Time before triggering NSS to low, and sending data(also between end of transmission, and NSS to high) is too long. How can i make this times shorter?

I tried to use

HAL_DMA_PollForTransfer(&hdma_spi1_tx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);

for detecting end of SPI DMA transmission but once it worked, and later when i changed something in CubeIDE it completely stoped working whole program...

int dmabusy = 0;
  while (1)
  {
      uint8_t testing[] = {5, 10, 15, 20, 25, 30};
      //HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
      dmaBusy = 1;
      GPIOB->BSRR = GPIO_BSRR_BS12;
      HAL_SPI_Transmit_DMA(&hspi1, testing, 6);
      while(dmaBusy == 1);
      GPIOB->BSRR = GPIO_BSRR_BR12;
      //HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);
      for(int i=0; i<80000; i++){ // OPOZNIACZ START
          asm("NOP");
      } // OPOZNIACZ STOP
  }
  /* USER CODE END 3 */
}



void HAL_SPI_TxCpltCallback (SPI_HandleTypeDef * hspi){
    dmaBusy=0;
}

logic analyser

Sink
  • 91
  • 1
  • 2
  • 9
  • Is DMA end of the transaction interrupt enabled? Why didn't you ask on elektroda – 0___________ Jul 25 '20 at 18:47
  • I have general interrupt enabled - this one "HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);". I was looking in the internet for information what function will let me to enable TCIF interrupt, but I haven't found. Can You show me that function? I didn't asked on elektroda, because I'm looking for answer on my problem, instead of being treat like $hit, like previous times i asked there. – Sink Jul 25 '20 at 19:20
  • oh i already found that - __HAL_DMA_ENABLE_IT(&hdma_spi1_tx, DMA_IT_TC ); – Sink Jul 25 '20 at 19:28
  • I would rather use registers for this kind of simple peripherals. Less hassle – 0___________ Jul 25 '20 at 20:38
  • @P__J__ tell me how can i describe register where is TCIF in code, to read from it? – Sink Jul 25 '20 at 21:17
  • Your main sin is magic libraries trust. Read Reference manual. Everything is there. BTW the register is called IFCR. – 0___________ Jul 25 '20 at 21:38
  • Thanks. You are right. Since I saw that driving GPIO from register is bit faster i try not to use HAL_writepin anymore. – Sink Jul 25 '20 at 21:44
  • I checked, and IFCR is used to clear, not to check flags – Sink Jul 25 '20 at 21:49
  • Yes ISR register is used to read. – 0___________ Jul 25 '20 at 21:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/218598/discussion-between-niko-and-p-j). – Sink Jul 25 '20 at 22:02

0 Answers0