2024-04-16 08:08 PM
Using NUCLEO H723ZG & STM32 CUBE IDE
Trying to send two 32bit data (0xA & 0xB) via spi1 (only two 32bit words per data pkg)
NOTE- set up nucleo to close loop back & connected MISO & MOSI / clk=~2.182MHz
SPI1 set to 32bit w/ interrupt
I load 0xA & 0xB in FIFO & then SPI_CR1_CSTART
The chip goes into SPI1_IRQHandler(void)
1)However, though I see the value of RXDR sequence thru 0xA&0XB in debug SFR display,
but I always read as 0 in program
2) The prog seems to enter the IRQ handler only once
I was wondering if someone can comment
-spent a lot of time reading thru the RM0468 ref manual SPI section-I must have missed something!
Here is the code snippet (this is the only peripheral i am using)
main()
{
...//set up generated by IDE here
//set up SPI1
NVIC_EnableIRQ(SPI1_IRQn);//enable SPI1 global interrupt
SPI1->CR1 &= ~SPI_CR1_SPE;//disable spi1
SPI1->CR2 = 0x2;//TSIZE = two words to transmit
SPI1->CFG1 = SPI1->CFG1 | 0x00000030;//(FIFO threshold=3)
SPI1->IER |= SPI_IER_RXPIE;//enable RXPIE
SPI1->CR1 |= SPI_CR1_SPE;//enable spi1
SPIBusy=0;
while (1)
{
if(SPIBusy==0)
{
SPIBusy=1;//reset inside SPI1_IRQHandler(void)
SPI1->TXDR = 0xA;//first word into FIFO
SPI1->TXDR = 0xB;//second word into FIFO
SPI1->CR1=SPI1->CR1 | SPI_CR1_CSTART; //start transfer now
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
here is the IRQ handler
void SPI1_IRQHandler(void)
{
/* USER CODE BEGIN SPI1_IRQn 0 */
/* USER CODE END SPI1_IRQn 0 */
//HAL_SPI_IRQHandler(&hspi1);
/* USER CODE BEGIN SPI1_IRQn 1 */
SPIBusy = 0;
SPIReceivedData1 = SPI1->RXDR;//SPIReceivedData1=0 -expecting 0xA
SPIReceivedData2 = SPI1->RXDR;//SPIReceivedData2=0 -expecting 0xB
/* USER CODE END SPI1_IRQn 1 */
}