1578 views|1 replies

1w

Posts

16

Resources
The OP
 

[Shanghai Hangxin ACM32F070 development board review] 7. Give the watchdog a thread [Copy link]

 

In my mind, threads are tasks and tasks are threads.

Last time I ran the RTX operating system in the watchdog routine, so this time I will create another task to bring the dog with me. After all, it was modified from the watchdog program, and it would be bad to change it away.

The first step is to change the parameters of the watchdog function

The previous program is void WDT_Reset_Test(void) and is changed to void WDT_Reset_Test(void const *argument)

If you don't change RTX in this way, it seems that it will not pass.

Step 2: Add an ID

osThreadId Dog;

Step 3: Create a task

Dog = osThreadCreate(osThread(WDT_Reset_Test), NULL);

The running results are as follows;

Full Program:

/*
  ******************************************************************************
  * [url=home.php?mod=space&uid=1307177]@File[/url] main.c
  * [url=home.php?mod=space&uid=159083]@brief[/url] main source File.
  ******************************************************************************
*/
#include "APP.h"
#include "cmsis_os.h"
#define UART_BAUD_RATE  115200

UART_HandleTypeDef UART2_Handle;
void led_Thread1 (void const *argument);

osThreadDef(led_Thread1, osPriorityNormal, 1, 0);
osThreadDef(WDT_Reset_Test,osPriorityNormal,1,0);

osThreadId T_led_ID1;
osThreadId Dog;
/************************************************************************
 * function   : Uart_Init
 * Description: Uart Initiation. 
 ************************************************************************/ 
void Uart_Init(void) 
{
    UART2_Handle.Instance        = UART2;    
    UART2_Handle.Init.BaudRate   = UART_BAUD_RATE; 
    UART2_Handle.Init.WordLength = UART_WORDLENGTH_8B;
    UART2_Handle.Init.StopBits   = UART_STOPBITS_1;
    UART2_Handle.Init.Parity     = UART_PARITY_NONE;
    UART2_Handle.Init.Mode       = UART_MODE_TX_RX_DEBUG;
    UART2_Handle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;
    
    HAL_UART_Init(&UART2_Handle);  
    
    /* UART_DEBUG_ENABLE control printfS */     
    printfS("MCU is running, HCLK=%dHz, PCLK=%dHz\n", System_Get_SystemClock(), System_Get_APBClock());       
}
/*********************************************************************************
* Function    : main
* Description : 
* Input       : 
* Outpu       : 
* Author      : CWT                         Data : 2020年
**********************************************************************************/
int main(void)
{
	  osKernelInitialize ();                    // initialize CMSIS-RTOS
    System_Init();
    Uart_Init(); 
    
    //WDT_Reset_Test(); 
	
	  T_led_ID1 = osThreadCreate(osThread(led_Thread1), NULL);
	  Dog = osThreadCreate(osThread(WDT_Reset_Test), NULL);
	  osKernelStart ();                         // start thread execution 

}


void led_Thread1 (void const *argument)
{
	while(1)
	{
	printfS("HELLO EEWORLD !!!"); 
	osDelay(500);
	}
}

This post is from Domestic Chip Exchange

Latest reply

The parameters of the watchdog function are really modified like the original poster's.   Details Published on 2022-11-6 09:28
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

1662

Posts

0

Resources
2
 

The parameters of the watchdog function are really modified like the original poster's.

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list