Skip to main content
LTech
Associate III
March 8, 2019
Question

Should I use xTaskCreate if I want to use UART?

  • March 8, 2019
  • 16 replies
  • 2853 views

I want to send data using UART, I've configured everything but I don't get any data output unfortunately.

My question is whether this can be because of the fact that I am doing nothing with xTaskCreate? When should xTaskCreate be used and should I use it in my case?

This topic has been closed for replies.

16 replies

Martin KJELDSEN
Principal III
March 9, 2019

Hi @LTech​,

You're not getting any data output from what exactly (What is your application trying to do)? You don't _need_ to use additional OS tasks, even with TouchGFX, to integrate with peripherals, but it's often a good idea depending on the complexity of your application.

Are you sure you've configured the UART correctly? Did you get a basic application working without TouchGFX? Maybe try some of the Cube Firmware examples.

Best regards,

Martin

LTech
LTechAuthor
Associate III
March 12, 2019

Hello @Martin KJELDSEN​ ​,

I am using TouchGFXDesigner 4.10.0

UPDATE: it is able to send my message via UART if I place

HAL_UART_Transmit_DMA(&MyUART, (uint8_t *) MyMessage, 7);

before the line

GRAPHICS_HW_Init();

inside main.cpp but then it won't display anything on the screen.

I want to send the data using HAL_UART_Transmit_DMA whenever I press a button that I've placed on the screen which is defined inside MainView.cpp but I cannot simply include the header file because it still won't find MyUART and MyMessage if I place it there.

LTech
LTechAuthor
Associate III
March 12, 2019

@Martin KJELDSEN​ If you can answer the following question, then my problem is solved:

Inside MainView.cpp I want to use HAL_UART_Transmit_DMA but it simply cannot find any of the UART functions. Including header files such as #include "stm32f769i_discovery.h" or #include "stm32f7xx_hal_uart.h" doesn't work (even giving the relative path doesn't work).

Any solution?

Martin KJELDSEN
Principal III
March 12, 2019

You should avoid mixing target specific code with GUI code (MainView.cpp) to keep things simple. Do the setup inside the MainViewPresenter by calling a transmit() method on the model instead. (The presenter has a pointer to the Model)

You said you were able to call the function before, so you must have set up the proper include paths, etc.

/Martin

LTech
LTechAuthor
Associate III
March 13, 2019

I've changed the code as you said,

Inside Model.cpp I have something like:

#ifndef SIMULATOR // optional

#include "stm32f769i_discovery.h"

#endif

void Model::SendMODE()

{

   HAL_UART_Transmit_DMA(&MyUART, (uint8_t *) MyMessage, 7);

}

but it seems when I click on Run Target inside Touchgfx designer, the compiler simply cannot find stm32f769i_discovery.h . The Makefile is also correct.

If I remove the line HAL_UART_Transmit_DMA(&MyUART, (uint8_t *) MyMessage, 7); it works but it simply doesn't include "stm32f769i_discovery.h" (for example when I remove the lines #ifndef SIMULATOR #endif and HAL_UART_Transmit_DMA(&MyUART, (uint8_t *) MyMessage, 7); it gives the error that it cannot find/include "stm32f769i_discovery.h".

Any possible solution?