解决温度采集延时问题

This commit is contained in:
2025-11-18 15:40:38 +08:00
parent 4f4a1635ab
commit daa4fd6bd3
12 changed files with 581 additions and 156 deletions

181
T21.C Normal file
View File

@@ -0,0 +1,181 @@
//****************************************************************************
// @Module Timer 21
// @Filename T21.C
// @Project CL2.0.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC886CLM-8FF
//
// @Compiler Keil
//
// @Codegenerator 1.3
//
// @Description: This file contains functions that use the T21 module.
//
//----------------------------------------------------------------------------
// @Date 2025/11/17 18:48:53
//
//****************************************************************************
// USER CODE BEGIN (T21_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (T21_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (T21_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (T21_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (T21_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (T21_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (T21_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (T21_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (T21_General,9)
// USER CODE END
//****************************************************************************
// @Function void T21_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the Timer 21
// function library. It is assumed that the SFRs used by this
// library are in their reset state.
//
// The following SFRs and SFR fields will be initialized:
// T21_RC2H/RC2L - reload/capture timer 21 register
// T21_T2H/T2L - timer 21 register
// EX2 - timer 21 interrupt enable
// T21_T2MOD - timer 21 mode register
// CP/RL2 - Capture/Reload select
// EXEN2 - External enable control
// TR2 - Timer21 run control
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2025/11/17
//
//****************************************************************************
// USER CODE BEGIN (T21_Init,1)
// USER CODE END
void T21_vInit(void)
{
// USER CODE BEGIN (T21_Init,2)
// USER CODE END
// -----------------------------------------------------------------------
// Operating Mode
// -----------------------------------------------------------------------
/// 16-bit timer function with automatic reload when timer 21 overflows
/// Prescaler enabled - input clock = fPCLK
/// the timer 21 resolution is .042 ?s
/// the timer 21 overflow is 1.000 ?s
/// timer 21 interrupt: enabled
/// timer 21 will be started
// -----------------------------------------------------------------------
// Register Initialization
// -----------------------------------------------------------------------
SET_RMAP();
T21_T2L = 0xE8; // load timer 21 register, low byte
T21_T2H = 0xFF; // load timer 21 register, high byte
T21_RC2L = 0xE8; // load timer 21 reload/capture register,
// low byte
T21_RC2H = 0xFF; // load timer 21 reload/capture register,
// high byte
T21_T2MOD = 0x10; // load timer 21 mode register
/// Timer 21 Interrupt enable bit is set in SHINT_vInit() function
// USER CODE BEGIN (T21_Init,3)
// USER CODE END
TR2 = 1; // start timer
RESET_RMAP();
} // End of function T21_vInit
// USER CODE BEGIN (T21_General,10)
// USER CODE END