cancel
Showing results for 
Search instead for 
Did you mean: 

I'm using S32cubeMX to create a project for a stm32L010; on a proprietary board we connected a SPI ST mems to USART2. I have 2 questions 1) I can't select MSBFIRST bit using standard HAL drivers. 2) it seems USART2 tx/rx lines have an internal shortcut

AGasp.1446
Associate II

1) CubeMX create a usart type port, without opportunity to use UART_AdvFeatureConfig(); I implemented by myself the setting of MSBFIRST bit and works fine.

2) using USART2 in synchronous mode, on the read operation tx and rx lines are exactly equal and on both ones I get wrong voltage level on (using oscilloscope)

10 REPLIES 10

2. There are no internal shorts between pins (except on the SO-8 package - do you use such?). Check your board.

JW

AGasp.1446
Associate II

I tried changing PA3(USART2TX) form AF to INPUT just before starting a read operation and now read operation is correct

AGasp.1446
Associate II

I tested my board and I didn't find any shortcut; as I wrote in previous message, changing temporarily PA2(USART2TX) (sorry, i made a mistake in previous message) the RX line reaches the correct voltage levels and I'm able to read data correctly

AGasp.1446
Associate II

I forgot, I'm using L010RB LQF64

What do you exactly mean by "read operation"?

Read out and check/post the USART and relevant GPIO registers content.

What are the hardware connections to the given pins?

JW

AGasp.1446
Associate II

here a part of the schematics and reading code

   cmd[0]=(IIS3DHHC_WHO_AM_I+IIS3DHHC_READ);                     // read who am i register

   HAL_GPIO_WritePin( GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);            // enable /CS2

//   HAL_USART_TransmitReceive(&husart2, cmd, type, 2, 100);            // first try, uncorrect reading

   HAL_USART_Transmit(&husart2, cmd, 1, 100);       // second try, transmit, disable pin, receive, correct reading                  

   disable_tx_usart2();                     // set PA2 pin (uasrt2tx) to input mode

   HAL_USART_Receive(&husart2, type, 1, 100); // read operation

   HAL_GPIO_WritePin( GPIOA, GPIO_PIN_1, GPIO_PIN_SET);

   enable_tx_usart2();                        // set back PA2 pin to usart2tx

0693W000003Qd38QAC.jpg

I don't see anything suspicious here...

Read out and post the USART2 registers content.

JW

AGasp.1446
Associate II

here the the USART2 registers condition before and after tx/rx operation; as a 2nd byte is transmitted, in this case i wrote 0xff. If I write 0x00, RDR an TDR will be 00 in the second screenshot.0693W000003Qfq2QAC.jpg

I can't see anything suspicious here either.

Sorry but I have no more idea what could be wrong.

JW