cancel
Showing results for 
Search instead for 
Did you mean: 

Problem On using HAL_SPI_Receive() function

JA.3
Associate

I'm new to ST-Micro controller, I m using STM32F429. I'm Receiving 8 bytes of data from SPI1 Port and transmitting the same data thru UART2 port to view in serial terminal. I m not supposed to view the HEX data. It is giving either ASCII or Unicode. How can I convert the data in microcontroller itself.

/* USER CODE BEGIN PV */

uint8_t ReadData[8]; // declared as global variable

void StartReceive(void)

{

HAL_SPI_Receive(&hspi1,&ReadData[0],8,100);

HAL_UART_Transmit(&huart2,&ReadData[0],8,100);

}

0693W00000CzzqDQAR.pngIn oscilloscope, I can verify the binary format data. There is no more problem in Clock, Data line, And Hardware NSS pin and all. I can probe all those lines outside.

When I saw the data in debug mode also It shows some characters only. If any one helps me in this, it will a great thing for me.

0693W00000CzzssQAB.pngIs there any format conversion does I have to do? or whether my declaration should be a character type?

1 REPLY 1
TDK
Guru

The STM32 just receives/sends raw data. It doesn't know or care if you interpret the raw data as ASCII or Unicode. That is something you would need to control on the receiving software, there is no way for the STM32 to control this.

Converting unicode to ASCII is nontrivial as there are way more than 127 Unicode characters. They don't all have ASCII equivalents.

If you feel a post has answered your question, please click "Accept as Solution".