cancel
Showing results for 
Search instead for 
Did you mean: 

STM32h745 SPI DMA not receiving the data

MDeva.1
Associate II

Hello,

I am working on STM32h745 controller. I am using the DMA for SPI configuration. I declare the buffer in the RAM2 , transmission is done properly but I did not receiving the data on MISO why?

/* MODIFICATION STARTS HERE */

 .buffer(NOLOAD) :

 {

  . = ALIGN (16);

   

  . = ABSOLUTE (0x30000020);

  *(.Write)

   

  . = ABSOLUTE (0x30000420);

  *(.Value)

   

  . = ABSOLUTE (0x30000820);

  *(.Read)

   

  . = ABSOLUTE (0x30000920);

  *(.Read_Value)

   

     

 } > RAM_D2

__attribute__ ((section(".Write"), used)) uint16_t Write[68];

__attribute__ ((section(".Value"), used)) uint16_t Value[68];

__attribute__ ((section(".Read"), used)) uint16_t Read[68];

__attribute__ ((section(".Read_Value"), used)) uint16_t Read_Value;

uint16_t Read_Value=0;

uint16_t Write[68];

uint16_t Value[68];

uint16_t Read[68];

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)

{

HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET);

}

void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)

{

SCB_InvalidateDCache_by_Addr ((uint32_t *)&Read_Value, sizeof(Read_Value));

HAL_GPIO_WritePin(GPIOE, LED2_Pin,GPIO_PIN_SET);

}

void DAC(void)

{

uint16_t W_Write[68]= {0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x001F,0x0020,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F,0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,0x003E,0x003F,0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,0x0060,0x001D,0x001E };

uint16_t V_Value[68]={0x0000,0x0E00,0x0000,0x0000,0x4000,0x4000,0x4000,0x4000,0x0000,0x1F00,0x1F00,0x1F00,0x1F00,0x0000,0x0000,0x0000,0x000E,0x0000,0x0000,0x0000,0x0000,0x0101,0x0101,0x0111,0xFFFF,0x0101,0x0101,0x0003,0x0000,0x5552,0x1554,0x3FFE,0x3FFE,0x4000,0x4000,0x4000,0x4000,0x0001,0x0200,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07D0,0x0000,0x0000,0x0000,0x03E8,0x0000,0x0000,0x0000,0x0BB8,0x0000,0x0000,0x0000,0x0FA0,0x0000,0x0000,0x0000,0x0004,0x0001,0x0001};

uint16_t R_Read[68]= {0x8000,0x8001,0x8002,0x8003,0x8004,0x8005,0x8006,0x8007,0x8008,0x8009,0x800A,0x800B,0x800C,0x000D,0x000E,0x801F,0x8020,0x8022,0x8023,0x8024,0x8025,0x8026,0x8027,0x8028,0x8029,0x802A,0x802B,0x802C,0x802D,0x802E,0x802F,0x8030,0x8031,0x8032,0x8033,0x8034,0x8035,0x8036,0x8037,0x803E,0x803F,0x8040,0x8041,0x8042,0x8043,0x8044,0x8045,0x8046,0x8047,0x8050,0x8051,0x8052,0x8053,0x8054,0x8055,0x8056,0x8057,0x8058,0x8059,0x805A,0x805B,0x805C,0x805D,0x805E,0x805F,0x8060,0x001D,0x001E};

int i=0,j=0,k=0;

  memcpy(Write,W_Write,sizeof(W_Write));

  memcpy(Value,V_Value,sizeof(V_Value));

  memcpy(Read,R_Read,sizeof(R_Read));

uint8_t s=0,s1=0,s2=0,s3=0;

for(i=0,j=0,k=0;i<68;i++,j++,k++)

{

HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_RESET);

while(HAL_SPI_Transmit_DMA(&hspi4, (uint8_t*)&Write[i], 1)==HAL_OK);

while(HAL_SPI_Transmit_DMA(&hspi4, (uint8_t*)&Value[j], 1)==HAL_OK);

HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_SET);

printf("s=%d s=%d W- A=%x, V=%x\n\r",s,s1,Write[i],Value[j]);

HAL_Delay(100);

HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);

HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_RESET);

while(HAL_SPI_Transmit_DMA(&hspi4, (uint8_t*)&Read[k], 1)==HAL_OK);

while(HAL_SPI_Receive_DMA(&hspi4, (uint8_t*)&Read_Value,1)==HAL_OK);

HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_SET);

printf("s=%d s=%d R- A=%x,V=%x\n\n\r",s2,s3,Read[k],Read_Value);

HAL_Delay(100);

HAL_GPIO_WritePin(GPIOE, LED2_Pin,GPIO_PIN_RESET);

HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);

Read_Value=0;

}

}

When transmission is complete led gets turn ON. But SPI is not reading the data what is issue?

1 REPLY 1
gbm
Lead II

There are many issues. Sending single frame using DMA makes no sense. For block transfer, use TransmitReceive.