2024-11-05 04:55 AM
hello!
i'm trying to make a project with the board SNK1M1 coupled with the NUCLEO-G071RB using azure ThreadX instead of FreeRTOS.
i'm able to replicate the example provided here:
or the video on youtube:
https://www.youtube.com/watch?v=cbdFHmMOMwk
and all work fine like in the video
BUT
if i change the Rtos with azure ThreadX nothing work anymore!
the code is compiled without problem, it seems to run (no hardfault error) but i can't find the board in the cube monitor UCPD
there is some additional step to use azure threadX instead FreeRTOS?
there is a tutorial of how to use with threadX?
thank you in advance!
Solved! Go to Solution.
2024-11-11 02:24 AM
hI @HFISTM
i have tryed your suggestion , i see the code in H5 repository e found that i have to call the USBPD_DPM_TimerCounter() manually
so have modificed my timer like this:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM6) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
if (htim->Instance == TIM6) {
USBPD_DPM_TimerCounter();
#if defined(_GUI_INTERFACE)
GUI_TimerCounter();
#endif
}
/* USER CODE END Callback 1 */
}
i have also configured the TX_TIMER_TICKS_PER_SECOND 1000 in the threadX tab to hacve a tick of 1 mS
but nothing changed! i'm unable to see the com port in the cube monitor UCPD software .
can i send to you my project? to take a look
thank you
2024-11-11 02:44 AM
2024-11-11 03:02 AM
hello @Nicolas P.
if i put a break point on the HAL_IncTick(); or USBPD_DPM_TimerCounter(); its breaking continously so i assume the tick is going.
i i break the code is always breaking in the _tx_thread_system_return(); in the file tx_thread_system_suspend
there is no trace on the cube monitor ucpd.
i don't have another thread created by me,
i have slavishly followed the ST tutorial on youtube:
https://www.youtube.com/watch?v=cbdFHmMOMwk&t
but i have selected azure threadX for operating system
and also:
1) make the tick per second 1000
2) make the timebase source TIM6
3) added
if (htim->Instance == TIM6) {
USBPD_DPM_TimerCounter();
#if defined(_GUI_INTERFACE)
GUI_TimerCounter();
#endif
}
to the HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
maybe there is some modification to enable the UCPD thread? is not automatic started?
thank you
2024-11-11 07:06 AM
hello @Nicolas P. @HFISTM
maybe you can look at the project to check if i'm missing something,
thank you
reguards
2024-11-12 12:54 AM
Hello @ABasi.2
I've briefly looked at your code and found maybe a hint on the issue.
In your ThreadX init function "tx_application_define()" you are:
I suggest you compare with the H5 project, especially this function in this file: STM32CubeH5/Projects/NUCLEO-H563ZI/Applications/USBPD/USBPD_SNK/AZURE_RTOS/App/app_azure_rtos.c at main · STMicroelectronics/STM32CubeH5
Hoping this will solve your issue.
Best regards!
2024-11-12 01:12 AM
hello @HFISTM
i understand your point but i have some question about your 2 sentence:
this is cube MX code, if is it mandatory to check the result why the code generated don't check?
with freeRtos enabled isn't necessary to manually ad this code, why with threadX is necessary ?
if i can suggest something i think is really helpfull if ST update the youtube example with version with threadX
i will check and update my code with your suggestion!
thank you!
2024-11-12 01:46 AM
HELLO @HFISTM
i think i found the issue,
cube MX is not generating the code for the GUI!
in the code for STM32H5 in the app_azure_rtos.c you find :
if (tx_byte_pool_create(&gui_interface_app_byte_pool, "GUI_INTERFACE App memory pool", gui_interface_byte_pool_buffer, GUI_INTERFACE_APP_MEM_POOL_SIZE) != TX_SUCCESS)
{
/* USER CODE BEGIN GUI_INTERFACE_Byte_Pool_Error */
/* USER CODE END GUI_INTERFACE_Byte_Pool_Error */
}
else
{
/* USER CODE BEGIN GUI_INTERFACE_Byte_Pool_Success */
/* USER CODE END GUI_INTERFACE_Byte_Pool_Success */
memory_ptr = (VOID *)&gui_interface_app_byte_pool;
status = GUI_InitOS(memory_ptr);
if (status != USBPD_OK)
{
/* USER CODE BEGIN MX_GUI_INTERFACE_Init_Error */
while(1)
{
}
/* USER CODE END MX_GUI_INTERFACE_Init_Error */
}
/* USER CODE BEGIN MX_GUI_INTERFACE_Init */
/* USER CODE END MX_GUI_INTERFACE_Init */
}
that is generated by cube MX!
but whit the G071RB the app_azure_rtos.c is:
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file app_azure_rtos.c
* @author MCD Application Team
* @brief app_azure_rtos application implementation file
******************************************************************************
* @attention
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "app_azure_rtos.h"
#include "stm32g0xx.h"
#include "usbpd.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN TX_Pool_Buffer */
/* USER CODE END TX_Pool_Buffer */
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN static UCHAR tx_byte_pool_buffer[TX_APP_MEM_POOL_SIZE] __ALIGN_END;
static TX_BYTE_POOL tx_app_byte_pool;
/* USER CODE BEGIN USBPD_Pool_Buffer */
/* USER CODE END USBPD_Pool_Buffer */
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
static UCHAR usbpd_byte_pool_buffer[USBPD_APP_MEM_POOL_SIZE];
static TX_BYTE_POOL usbpd_app_byte_pool;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/**
* @brief Define the initial system.
* @param first_unused_memory : Pointer to the first unused memory
* @retval None
*/
VOID tx_application_define(VOID *first_unused_memory)
{
/* USER CODE BEGIN tx_application_define */
/* USER CODE END tx_application_define */
VOID *memory_ptr;
if (tx_byte_pool_create(&tx_app_byte_pool, "Tx App memory pool", tx_byte_pool_buffer, TX_APP_MEM_POOL_SIZE) != TX_SUCCESS)
{
/* USER CODE BEGIN TX_Byte_Pool_Error */
/* USER CODE END TX_Byte_Pool_Error */
}
else
{
/* USER CODE BEGIN TX_Byte_Pool_Success */
/* USER CODE END TX_Byte_Pool_Success */
memory_ptr = (VOID *)&tx_app_byte_pool;
if (App_ThreadX_Init(memory_ptr) != TX_SUCCESS)
{
/* USER CODE BEGIN App_ThreadX_Init_Error */
/* USER CODE END App_ThreadX_Init_Error */
}
/* USER CODE BEGIN App_ThreadX_Init_Success */
/* USER CODE END App_ThreadX_Init_Success */
}
if (tx_byte_pool_create(&usbpd_app_byte_pool, "USBPD App memory pool", usbpd_byte_pool_buffer, USBPD_APP_MEM_POOL_SIZE) != TX_SUCCESS)
{
/* USER CODE BEGIN USBPD_Byte_Pool_Error */
/* USER CODE END USBPD_Byte_Pool_Error */
}
else
{
/* USER CODE BEGIN USBPD_Byte_Pool_Success */
/* USER CODE END USBPD_Byte_Pool_Success */
memory_ptr = (VOID *)&usbpd_app_byte_pool;
if (MX_USBPD_Init(memory_ptr) != TX_SUCCESS)
{
/* USER CODE BEGIN MX_USBPD_Init_Error */
/* USER CODE END MX_USBPD_Init_Error */
}
/* USER CODE BEGIN MX_USBPD_Init_Success */
/* USER CODE END MX_USBPD_Init_Success */
}
}
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
in the file IOC the GUI_interface is enabled , HwBoardVersionName and PDTTypeName compiled but seems the cube doesn't create the code
am 'i wrong and i'm missing something?
thank you!
2024-11-12 02:16 AM
Yes you are right this is an issue with CubeMX.
CubeMX is meant to be a static configuration tool, and USBPD application is a bit out of scope as it is highly applicative and not only configuration (like for a UART or I2C peripheral for instance).
However the tool was tweaked as much as possible to be able to create a full USBPD application (as you can see in the wiki or video).
In your case the issue is that you are using ThreadX as an extension pack, as it is not native for G0 (freertos is). Thus, the USBPD part is handled separately. I will open a ticket to track the issue, thank you for your patience.
I highly recommend to make a file diff between H5 (native threadx, with all USBPD code) and your application like you started, to ensure you have all applicative code needed for your need.
Thank you and regards
2024-11-12 02:21 AM
thank you! @HFISTM
i will try!
if i succed i write to you with the modification i made
Thank you for your help!
2024-11-29 12:34 AM
hello!
i'm trying to modify the ST example STM32CubeH5/Projects/NUCLEO-H563ZI/Applications/USBPD/USBPD_SNK/AZURE_RTOS/App/app_azure_rtos.c at main · STMicroelectronics/STM32CubeH5 you advised to me
the example work great, if i connect the USB -C user port of the nucleo-h563zi board to my usb-c output of the computer i have some messages on the cubemonitor and see a 5V on the board
noy i want to request a different voltage of coarse so i added in the ioc file via cube ide a new PDO 1 with 15V and 1000mA
nothing appen.. i understand that to have 15V the source have to vapable to output the 15V
so my first question is : can you advise me of a source device able to output all the different voltages that i can buy to try ?
also have a second question:
did you have a example that manage the request to change the requested voltage in the code ?
thank you