cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Repeated Transmission Issue [Possible Processor Reset Problem]

AMerc.8
Associate II

Hello all,

I am currently working on a project with the STM32H743VIHX and I have been having some issues getting SPI communication with an external DAC working. The test I have built is supposed to transmit 24bits of data to the external DAC and record the output on one of the STM32's ADC's. I have a code snippet below but the full project is zipped for further detail:

typedef struct __attribute__((__packed__)) DACDataPacket
{
	unsigned int bit23				:1;
	unsigned int bit22				:1;
	unsigned int command			:3;
	unsigned int address			:3;
	unsigned int dataUpperHalf	  	:8;
	unsigned int dataLowerHalf		:8;
}DACDataPacket;
 
#define COMMAND		0b000
#define ADDRESSB	0b001
#define MAXOUTPUT	0x00
 
DACDataPacket MyPacket;
 
MyPacket.command 		  = COMMAND;
MyPacket.address 		  = ADDRESSB;
MyPacket.dataUpperHalf    = MAXOUTPUT;
MyPacket.dataLowerHalf    = MAXOUTPUT;
 
uint8_t spiSendBuff[3];
 
 
spiSendBuff[0] = (MyPacket.address) | (MyPacket.command << 3);
spiSendBuff[1] = MyPacket.dataUpperHalf;
spiSendBuff[2] = MyPacket.dataLowerHalf;
 
uint16_t sizeof_SpiSendBuff = sizeof(spiSendBuff);
 
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_4,GPIO_PIN_RESET);
 
HAL_SPI_Transmit_IT(&hspi4,spiSendBuff,3);
 
uint32_t raw = 0;
while(1)
{
	HAL_ADC_Start(&hadc3);
	HAL_ADC_PollForConversion(&hadc3,HAL_MAX_DELAY);
	raw = HAL_ADC_GetValue(&hadc3);
}

I am also utilizing a call back function to raise the chip select line after all of the data is sent as shown below:

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef* hspi)
{
	HAL_GPIO_WritePin(GPIOE,GPIO_PIN_4,GPIO_PIN_SET);
 
}

I have included the SPI4 Init function below:

When I run this firmware on my board I get the following output on my logic analyzer:

0693W00000aJZU8QAO.png 

Zooming into the first transmission I see that following :

0693W00000aJZUOQA4.pngThe data seems to be sent as expected. What is strange is the multiple transmissions shown in the first screen capture. If I zoom into the second transmission I get the following:

0693W00000aJZUwQAO.pngThe select line seems to drop out and then the select line is pulled high again part way through the second transmission. I have attached the .sal file from the logic analyzer as well as a csv file containing all of the data below as well in SPI_Transmit_Issue.zip

My current theory is that the processor is resetting for some reason. When I add a break point to the on the HAL_SPI_Transmit_IT function It is reached multiple times even though main should get trapped in the while loop performing ADC captures.

I would appreciate any thoughts anyone has. Please feel free to ask any clarifying questions.

1 ACCEPTED SOLUTION

Accepted Solutions
AMerc.8
Associate II

I ended up figuring out the Issue. IWDG1 is activated by default when generating the Hal files, disabling it fixed my issue.

View solution in original post

1 REPLY 1
AMerc.8
Associate II

I ended up figuring out the Issue. IWDG1 is activated by default when generating the Hal files, disabling it fixed my issue.