November 22, 2024, 03:19:11 PM

Olimex STM32-E407 and ARM-USB-OCD-H

Started by lim, October 29, 2020, 02:54:29 AM

Previous topic - Next topic

lim

I tried to setup the debugging environment using the printf through a UART3 provided by ARM-USB-OCD-H. I presume UART-3 as it is being stated in section 6.11 (BOOT pads) in the user manual.

Somehow, I am puzzled how or what setting the UART3 in the Olimex STM32 board should be, and what coding are needed in my program.

Appreciate your comment, please?

LubOlimex

I don't know what printf has to do with debugging.

ARM-USB-OCD-H has two interfaces - one is the JTAG interfaces suitable for programming and debugging targets like STM32-E407; the other is RS232-USB convertor interface that can NOT be used for debugging and programming, it is an extra for people that need RS232 interface but their PC doesn't have RS232 (like most modern personal computers). The RS232-USB interface can't not be used for JTAG debugging. It has nothing to do with debugging, it is a side extra.
Technical support and documentation manager at Olimex

lim

My bad, the wording "debugging" has caused confusion. I use the printf(), extra information for judging the right or wrong my my coding or logic. Can you please share how to set that up, please?

lim

I have segment of the code here. But not getting anything from the DB9 COM Port.

Tx(ARM-USB-OCD-H)<->Tx(Pin4) on Olimex STM32-E407
Rx(ARM-USB-OCD-H)<->Tx(Pin3) on Olimex STM32-E407
GRD(ARM-USB-OCD-H)<->GRD(Pin2)on Olimex STM32-E407

-----------------
#ifdef __GNUC__
  /* With GCC, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */

-----------------
UART3 setting
static void MX_USART3_UART_Init(void)
{

  /* USER CODE BEGIN USART3_Init 0 */

  /* USER CODE END USART3_Init 0 */

  /* USER CODE BEGIN USART3_Init 1 */

  /* USER CODE END USART3_Init 1 */
  huart3.Instance = USART3;
  huart3.Init.BaudRate = 115200;
  huart3.Init.WordLength = UART_WORDLENGTH_8B;
  huart3.Init.StopBits = UART_STOPBITS_1;
  huart3.Init.Parity = UART_PARITY_NONE;
  huart3.Init.Mode = UART_MODE_TX_RX;
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART3_Init 2 */
  /* Output a message on Hyperterminal using printf function */
    printf("\n\r UART3 Printf Example: retarget the C library printf function to the UART\n\r");
  /* USER CODE END USART3_Init 2 */

}


/**
  * @brief  Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
  HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);

  return ch;
}

Any comments?

LubOlimex

The hardware connections you established are dangerous. The voltage levels are not compatible. The ARM-USB-OCD-H has RS232 levels. You need level shifter at STM32-E407. Refer to STM32-P407's design and schematic that has two RS232 ports:

https://www.olimex.com/Products/ARM/ST/STM32-P407/
Technical support and documentation manager at Olimex

lim

Have purchased the level shifters. Any comments on the code, please?

LubOlimex

Tx(Pin4) on Olimex STM32-E407
Tx(Pin3) on Olimex STM32-E407

When you wrote that, did you mean Pin #3 and Pin #4 from the UEXT? These are PC6/USART6_TX and PC7/USART6_RX. In your code you seem to use USART3, while it should be USART6...

Refer to the schematic to identify pins and refer to the chip's datasheet to connect the pin with the available interface:

https://github.com/OLIMEX/STM32F4/blob/master/HARDWARE/STM32-E407/STM32-E407_Rev_F.pdf

https://www.st.com/resource/en/datasheet/dm00037051.pdf

This is not something trivial unfortunately, and we don't have the practice to debug customer code.
Technical support and documentation manager at Olimex

lim

hi, Sorry it was not my intention for you to debug the code, but have a glance if it makes sense for using USART3. The pins are from HN1X4-Boot connector, where connects to USART3. Anyway, appreciate your comments so far. Cheers!

lim

Correction, the correct pins are #1=TX, #2=RX #3=GRD, #4=3.3V. Hope this clarifies the confusion.

LubOlimex

Do you really need to connect the power?

Maybe test another USART. Also it might be good idea to test with another USB-serial cable instead of the serial of ARM-USB-OCD-H(something like https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-SERIAL-F/ or similar 3.3V). These tests would limit the possibilities.

I've also found these related USART attempts with E407 from the past:

https://www.hexnut.net/2015/07/rx-tx-of-usart-is-easy-right.html

https://www.olimex.com/forum/index.php?topic=1356.0

https://www.olimex.com/forum/index.php?topic=45.0
Technical support and documentation manager at Olimex

lim

#10
I have tested it by shorting the RX and TX of the ARM-USB-OCD-H, and sending a text messages to the /dev/ttyUSB0, the Minicom was showing up the text messages. Hence, the ARM-USB-OCD-H  is well. However, checked with Scope, and I did't get any signals from the Olimex board be it Uart3 or Uart6. I was wondering if what is wrong with the code.

Tried by replaced with the USB-serial cable. Passed loopback test, but it behaved the same when running the code/

lim

#11
I have got it resolved. Followed the instruction here, https://shawnhymel.com/1873/how-to-use-printf-on-stm32/.