2018-01-23 04:24 AM
Hi,
I am developping an application with a STM32F746ZG using the SPI interrupt to send data to a DAC. I am using the HAL_SPI_Transmit_IT() function to send this data in order to send a waveform. The fact is that I want to continuously send the waveform (I want aperiodic waveform to watch it in the oscilloscope) calling multiple times the function after the SPI transfer is complete.
For that purpouse I am using the HAL_SPI_TxCpltCallback() so I can set a flag when one period of the waveform has been send to the DAC and testing this flag in the infinite loop in the main function.
The problem is that the second time I call the HAL_SPI_Transmit_IT() function the interrupt never takes place.
Is this a good way to generate a specific waveform using the SPI to send the data to an external DAC?
Below you can see a snippet of the code,
int main(void)
{ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI3_Init(); /* SPI is ready */ wTransferState = TRANSFER_COMPLETE; /* Infinite loop */ while (1) { if(wTransferState == TRANSFER_COMPLETE){ if(HAL_SPI_Transmit_IT(&hspi3, (uint8_t*)aTxBuffer, 32) != HAL_OK){ _Error_Handler(__FILE__, __LINE__); } // wait again wTransferState = TRANSFER_WAIT; } } }...
....
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef* hspi){
wTransferState = TRANSFER_COMPLETE; /* Toogle the LED for visualization porpouses */ HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);}Thanks in advanced,
Omar
#stm32f7-hal #dac #spi-communication