cancel
Showing results for 
Search instead for 
Did you mean: 

MISO Stays High

EthanMankins
Associate III

I am using SPI to communicate between STM32H7B3I-DK (master) and Nucleo-H743ZI(Slave). My Data transmits as expected; however, after transmission the MISO line Stays high. I have Master Keep IO State Enabled on both.

I am not using HW NSS, and have setup my own NSS(nCS)


SLAVE SPI:

 

  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_SLAVE;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 0x0;
  hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
  hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
  hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
  hspi1.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  hspi1.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
  hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
  hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
  hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
  hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }

[ISRs]
// /CS handler
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
	if (GPIO_Pin == GPIO_PIN_14) {
		if(HAL_GPIO_ReadPin(nCS_GPIO_Port, nCS_Pin) == GPIO_PIN_RESET){
			txBuffer = pPacketSlave->ProcessCS(true);						//prep transmit 0 for first byte
        	__HAL_SPI_ENABLE(&hspi1);										//begin SPISetup
        	__HAL_SPI_ENABLE_IT(&hspi1, SPI_IT_RXP | SPI_IT_TXP);
        	__HAL_SPI_CLEAR_OVRFLAG(&hspi1);
        	__HAL_SPI_CLEAR_EOTFLAG(&hspi1);
        	__HAL_SPI_CLEAR_FREFLAG(&hspi1);							//end SPISetup

		}
	}
	__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
}

void spiISRSTM(SPI_HandleTypeDef *hspi) {

	if (hspi->Instance->SR & SPI_FLAG_TXP) {
		HAL_GPIO_WritePin(nFPINT_GPIO_Port, nFPINT_Pin, GPIO_PIN_RESET);//Lower nFPINT

		(*(__IO uint8_t *)&hspi->Instance->TXDR) = 5;					// transmit
		__HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXP);							// disable TXP
		while(!__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXC)){}
		byteXd = 1;
	}

	//Receive if ready
	if (hspi->Instance->SR & SPI_FLAG_RXP) {
    	rxBuffer = (*(__IO uint8_t *)&hspi->Instance->RXDR);
    	byteRd = 1;
    	__HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXP);
	}
	pPacketSlave->ProcessSPI();										//Process SPI data
	HAL_GPIO_WritePin(nFPINT_GPIO_Port, nFPINT_Pin, GPIO_PIN_SET);	//Raise nFPINT

	__HAL_SPI_CLEAR_OVRFLAG(hspi);
	__HAL_SPI_CLEAR_EOTFLAG(hspi);
	__HAL_SPI_CLEAR_FREFLAG(hspi);


}

 

Master SPI:

 

  hspi2.Instance = SPI2;
  hspi2.Init.Mode = SPI_MODE_MASTER;
  hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi2.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi2.Init.NSS = SPI_NSS_SOFT;
  hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi2.Init.CRCPolynomial = 0x0;
  hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
  hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
  hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
  hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
  hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
  hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
  hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE;
  hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
  if (HAL_SPI_Init(&hspi2) != HAL_OK)
  {
    Error_Handler();
  }

[ISRs]


void spiISRSTM(SPI_HandleTypeDef *hspi) {

	if (hspi->Instance->SR & SPI_FLAG_TXP) {
		SET_BIT(hspi->Instance->CR1, SPI_CR1_CSTART);					// start SPI master
		HAL_GPIO_WritePin(GPIOI, GPIO_PIN_0, GPIO_PIN_RESET);  			// Pull CS low
		(*(__IO uint8_t *)&hspi->Instance->TXDR) = txBuffer;			// transmit
		__HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXP);							// disable TXP
		while(!__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXC)){}
		HAL_GPIO_WritePin(GPIOI, GPIO_PIN_0, GPIO_PIN_SET);   	 		// Pull CS high
		byteXd = 1;
	}

	//Receive if ready
	if (hspi->Instance->SR & SPI_FLAG_RXP) {
    	rxBuffer = (*(__IO uint8_t *)&hspi->Instance->RXDR);
    	byteRd = 1;
    	__HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXP);
	}

	__HAL_SPI_CLEAR_OVRFLAG(hspi);
	__HAL_SPI_CLEAR_EOTFLAG(hspi);
	__HAL_SPI_CLEAR_FREFLAG(hspi);
}

 

0 REPLIES 0