cancel
Showing results for 
Search instead for 
Did you mean: 

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

CBand.1
Associate II

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 .

14 REPLIES 14
prain
Senior III

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

Thanks prain.

PFA, Source code.

hi prain,

please can you give some info on this.

prain
Senior III

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
Senior III

HAL_UART_Emul_MspInit ?

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
Senior III

Did you uncomment these lines?

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

 //{}

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

prain
Senior III

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