Skip to main content
CBand.1
Associate II
July 28, 2020
Question

i have ported the Emulated UART Code for STM32L431CC from the STM32F401RE.

  • July 28, 2020
  • 6 replies
  • 2608 views

peripheral settings done properly.

STM32F401RE -- has settings DMA2 & GPIOA (PIN_10 & PIN_11).

STM32L431CC -- But i have configured -- DMA1 & GPIOB(PIN_10, PIN_11).

Data Transmission & Reception not happening.

any suggestions .

This topic has been closed for replies.

6 replies

prain
Visitor II
July 28, 2020

provide more info, code , register image captures , ...

CBand.1
CBand.1Author
Associate II
July 28, 2020

Thanks prain.

PFA, Source code.

prain
Visitor II
July 31, 2020

why do you comment thease lines in main?

//while (__HAL_UART_EMUL_GET_FLAG(&UartEmulHandle, UART_EMUL_FLAG_TC) != SET)

 //{}

It should be there to verify that transmit phase have been completed. without that usart and DMA settings will overwrited by next function.

Also in debug mode step into

HAL_UART_Emul_Transmit_DMA function and check that settings are properly written to DMA and GPIO.

read the below list and check that all steps are done:

The UART Emulation HAL driver can be used as follows:

  (#) Declare a UART_Emul_HandleTypeDef handle structure.

  (#) Initialize the UART Emulation low level resources by implementing the HAL_UART_Emul_MspInit() API:

    (##) Enable the UART_EMUL clock

    (##) UART Emulation port declaration

      (+++) UART pins configuration: TxPinNumber and RxPinNumber

      (+++) Enable the clock for the GPIOs

  (#) Program the Baud Rate, Word Length, Stop Bit, Parity,

     and Mode(Receiver/Transmitter) in the huart Emul Init structure.

  (#) Initialize the UART Emulation registers software by calling the HAL_UART_Emul_Init() API.

    -@- The specific UART Emulaion Handle (Transmission complete, Reception complete

      and Transfer Error) will be managed using the macros HAL_UART_Emul_TxCpltCallback(),

HAL_UART_Emul_RxCpltCallback() and __HAL_UART_Emul_TranferError() inside the transmit

      and receive process.

    -@- These API's(HAL_UART_Emul_Init() configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)

    by calling the customed HAL_UART_Emul_MspInit() API.

  (#) Three modes of operations are available within this driver:

   *** UART Emulation mode IO operation ***

   ===================================

   [..]

    (+) Send an amount of data in non blocking mode (DMA) using HAL_UART_Emul_Transmit_DMA()

    (+) At transmission end of transfer HAL_UART_Emul_TxCpltCallback is executed and user can

      add his own code by customization of function pointer HAL_UART_Emul_TxCpltCallback

    (+) Receive an amount of data in non blocking mode (DMA) using HAL_UART_Emul_Receive_DMA()

    (+) At reception end of transfer HAL_UART_Emul_RxCpltCallback is executed and user can

      add his own code by customization of function pointer HAL_UART_Emul_RxCpltCallback

    (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can

      add his own code by customization of function pointer HAL_UART_Emul_ErrorCallback

   *** UART Emulation HAL driver macros list ***

   =============================================

   [..]

    Below the list of most used macros in UART Emulation HAL driver.

   (+) __HAL_UART_EMUL_GET_FLAG : Checks whether the specified UART Emulation flag is set or not

   (+) __HAL_UART_EMUL_CLEAR_FLAG : Clears the specified UART Emulation pending flag

   (+) __HAL_UART_EMUL_SET_FLAG : Set the specified UART Emulation flag

prain
Visitor II
July 31, 2020

HAL_UART_Emul_MspInit ?

CBand.1
CBand.1Author
Associate II
July 31, 2020

ya this function available in stm32l4xx_hal_msp.c

currently i am facing the issue multiple bytes not working.

I am able send & receive 1byte data.

prain
Visitor II
July 31, 2020

Did you uncomment these lines?

​//while (__HAL_UART_EMUL_GET_FLAG(&UartEmulHandle, UART_EMUL_FLAG_TC) != SET)

 //{}

CBand.1
CBand.1Author
Associate II
July 31, 2020

ya tried, after the 1st byte Transmitting the next bytes are not Transmitting.

prain
Visitor II
July 31, 2020

see line 348 in stm32l4xx_hal_uart_emul.c

TIM_CCxChannelCmd(TIM6, TIM_CHANNEL_1, TIM_CCx_ENABLE);

According to datasheet, TIM6 have no CCX (capture/compare) channel. It is a basic timer. Try to use another timer that have at least one CCX channel

CBand.1
CBand.1Author
Associate II
July 31, 2020

TIM_CCxChannelCmd(TIM1, TIM_CHANNEL_1, TIM_CCx_ENABLE);

i have configured TIM1.

CBand.1
CBand.1Author
Associate II
July 31, 2020

can you please share the datasheet, which one your referring.

subhra209
Visitor II
August 10, 2020

I have some doubt ?????????

I implemented one softuart in STM32L476ZE , it is working

but i want two softuart, simultaneously it is not working ,

Is there any limitation for that ?

if you want i can share the DMA configuration and flow control.