cancel
Showing results for 
Search instead for 
Did you mean: 

UART Emulation AN4457 - is it possible to use it via CubeMx?

FCamp.1
Associate III

Hello,

i was looking for some library to simulate UART on STM32 F4 MCU and i came across Application note AN4457. The note is clear in explaining how STSW-STM32156 firmware package provide such emulation and it looked really perfect for my case. Problem is that it's really difficult for me to understand how to implement such software in my project. Is there a way to import this middleware library inside CubeMX?

  • There are exemples in the package but informations how to import and include files are missing and links are dusted inside 20 files, that's really driving me crazy.

Thanks a lot

Filippo

3 REPLIES 3
TDK
Guru

HAL doesn't have software UART emulation built-in. You would need to import the code into your project and treat it as user code. There are instruction at the top of the source file as to how to use it.

   ==============================================================================
                        ##### How to use this driver #####
   ==============================================================================
  [..]
    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

If you feel a post has answered your question, please click "Accept as Solution".
FCamp.1
Associate III

Thanks a lot TDK.

I seen indeed this explanation but here it's exactly where the problem come from for me.

In fact, although there are indications these are very fuzzy to my understanding.

For instance it says to implement HAL_UART_Emul_MspInit() in order to declare pin configuration and so on... point is that i have no idea where to declare this function and what is the configuration of such pins or timers or EXTI. Should i configure for instance PINs inside CubeMx, create macros to link them and try to report inside this function? or the function will configure everything simply passing port and pin number?

I checked the example and it's really hard to reverse engineering what is inside and find things described above.

Surely it's clear for eyes more into ST HAL framework, but not mines.

I'll try something and if i manage to make it working I'll try to describe a step by step for someone else convenience.

Meantime if someone have some indication or examples it will be more then welcome.

Thanks again,

Filippo

Sai_Krishna
Associate

Hi, 
How did you import these files with the STM32CubeMX generated files? and How did you manage the configurartion for emul_uart?
Could you please show me the sample code?