Skip to main content
AGasp.1446
Associate II
September 2, 2020
Question

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 shortc

  • September 2, 2020
  • 10 replies
  • 2016 views

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)

This topic has been closed for replies.

10 replies

waclawek.jan
Super User
September 2, 2020

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
September 2, 2020

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
September 2, 2020

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
September 2, 2020

I forgot, I'm using L010RB LQF64

waclawek.jan
Super User
September 2, 2020

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
September 3, 2020

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

waclawek.jan
Super User
September 3, 2020

I don't see anything suspicious here...

Read out and post the USART2 registers content.

JW

AGasp.1446
Associate II
September 3, 2020

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

waclawek.jan
Super User
September 3, 2020

I can't see anything suspicious here either.

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

JW

AGasp.1446
Associate II
September 4, 2020

what's wrong is RSR register; using a oscillosciope (LeCroy 600Mhz), on the second operation (rx) I see a try to send the correct code of the mems (0x11) with wrong voltage levels, depending on the value in TDR register; both USART2TX/RX have exactly the same behaviour, so even on tx I see the same waveform of rx.

Anyway thanks for your attention & time, I can't spend more time for this stuff as I'm not blocked on it.