cancel
Showing results for 
Search instead for 
Did you mean: 

STM32+HAL+SPI

bodnarchuk
Associate
Posted on June 01, 2016 at 17:01

Hi

I'm trying to communicate with ADC through SPI interface with HAL layer and ended up with issues.

At start I configure adc:

HAL_SPI_Transmit(&hspi1, &SDATAC, 1, 3); //0x16

HAL_GPIO_WritePin(GPIOC, START_Pin, GPIO_PIN_SET);

HAL_SPI_Transmit(&hspi1, WREG1, 3, 3); {0x43, 0x00, 0x00}

HAL_SPI_Transmit(&hspi1, WREG2, 3, 3);  {0x42, 0x00, 0x30}

HAL_SPI_Transmit(&hspi1, WREG3, 4, 3);   {0x4a, 0x01, 0x06, 0x0f}

HAL_SPI_Transmit(&hspi1, &RDATAC, 1, 3); //0x12

and waiting for falling edge interrupt(data ready signal from adc):

void EXTI9_5_IRQHandler(void)

{

HAL_SPI_TransmitReceive_DMA(&hspi1, NOP, cdata, 6); 

 

//NOP = {0xff, 0xff, 0xff,}

//cdata[3]

  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9);

}

And here's what I get:

0690X00000605OHQAY.png

Why after transmitting and receiving 6 bytes as specified, my previous data being transmitted(HAL_SPI_Transmit(&hspi1, WREG1, 3, 3) WREG = {0x43, 0x00, 0x00})?

0 REPLIES 0