Skip to main content
LTech
Associate III
Mar 8, 2019 11:53 AM UTC
Question

Should I use xTaskCreate if I want to use UART?

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
Mar 9, 2019 1:00 AM UTC

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
Mar 12, 2019 10:40 AM UTC

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
Mar 12, 2019 12:27 PM UTC

@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
Mar 12, 2019 12:36 PM UTC

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
Mar 13, 2019 8:38 AM UTC

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?