C51 COMPILER V9.59.0.0 STC8A_TIMER 06/10/2021 10:10:14 PAGE 1 C51 COMPILER V9.59.0.0, COMPILATION OF MODULE STC8A_TIMER OBJECT MODULE PLACED IN .\list\STC8A_Timer.obj COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE STC8A_Timer.c OMF2 OPTIMIZE(8,SPEED) BROWSE DEBUG PRINT(.\list\STC8A_Tim -er.lst) TABS(2) OBJECT(.\list\STC8A_Timer.obj) line level source 1 /*---------------------------------------------------------------------*/ 2 /* --- STC MCU Limited ------------------------------------------------*/ 3 /* --- STC 1T Series MCU Demo Programme -------------------------------*/ 4 /* --- Mobile: (86)13922805190 ----------------------------------------*/ 5 /* --- Fax: 86-0513-55012956,55012947,55012969 ------------------------*/ 6 /* --- Tel: 86-0513-55012928,55012929,55012966 ------------------------*/ 7 /* --- Web: www.STCMCU.com --------------------------------------------*/ 8 /* --- Web: www.STCMCUDATA.com ---------------------------------------*/ 9 /* --- QQ: 800003751 -------------------------------------------------*/ 10 /* Èç¹ûÒªÔÚ³ÌÐòÖÐʹÓô˴úÂë,ÇëÔÚ³ÌÐòÖÐ×¢Ã÷ʹÓÃÁËSTCµÄ×ÊÁϼ°³ÌÐò */ 11 /*---------------------------------------------------------------------*/ 12 13 #include "STC8A_Timer.h" 14 15 //======================================================================== 16 // º¯Êý: u8 Timer_Inilize(u8 TIM, TIM_InitTypeDef *TIMx) 17 // ÃèÊö: ¶¨Ê±Æ÷³õʼ»¯³ÌÐò. 18 // ²ÎÊý: TIMx: ½á¹¹²ÎÊý,Çë²Î¿¼timer.hÀïµÄ¶¨Òå. 19 // ·µ»Ø: ³É¹¦·µ»Ø SUCCESS, ´íÎó·µ»Ø FAIL. 20 // °æ±¾: V1.0, 2012-10-22 21 //======================================================================== 22 u8 Timer_Inilize(u8 TIM, TIM_InitTypeDef *TIMx) 23 { 24 1 if(TIM == Timer0) 25 1 { 26 2 Timer0_Stop(); //Í£Ö¹¼ÆÊý 27 2 if(TIMx->TIM_Mode >= TIM_16BitAutoReloadNoMask) return FAIL; //´íÎó 28 2 TMOD = (TMOD & ~0x03) | TIMx->TIM_Mode; //¹¤×÷ģʽ,0: 16λ×Ô¶¯ÖØ×°, 1: 16λ¶¨Ê±/¼ÆÊý, 2: 8λ×Ô¶¯ÖØ×°, 3: - ²»¿ÉÆÁ±Î16λ×Ô¶¯ÖØ×° 29 2 if(TIMx->TIM_ClkSource > TIM_CLOCK_Ext) return FAIL; 30 2 Timer0_CLK_Select(TIMx->TIM_ClkSource); //¶ÔÍâ¼ÆÊý»ò·ÖƵ, ¶¨Ê±12T/1T 31 2 Timer0_CLK_Output(TIMx->TIM_ClkOut); //Êä³öʱÖÓʹÄÜ 32 2 T0_Load(TIMx->TIM_Value); 33 2 Timer0_Run(TIMx->TIM_Run); 34 2 return SUCCESS; //³É¹¦ 35 2 } 36 1 37 1 if(TIM == Timer1) 38 1 { 39 2 Timer1_Stop(); //Í£Ö¹¼ÆÊý 40 2 if(TIMx->TIM_Mode >= TIM_16BitAutoReloadNoMask) return FAIL; //´íÎó 41 2 TMOD = (TMOD & ~0x30) | (TIMx->TIM_Mode << 4); //¹¤×÷ģʽ,0: 16λ×Ô¶¯ÖØ×°, 1: 16λ¶¨Ê±/¼ÆÊý, 2: 8λ×Ô¶¯Ö -Ø×°, 3: Í£Ö¹¹¤×÷ 42 2 if(TIMx->TIM_ClkSource > TIM_CLOCK_Ext) return FAIL; 43 2 Timer1_CLK_Select(TIMx->TIM_ClkSource); //¶ÔÍâ¼ÆÊý»ò·ÖƵ, ¶¨Ê±12T/1T 44 2 Timer1_CLK_Output(TIMx->TIM_ClkOut); //Êä³öʱÖÓʹÄÜ 45 2 T1_Load(TIMx->TIM_Value); 46 2 Timer1_Run(TIMx->TIM_Run); 47 2 return SUCCESS; //³É¹¦ 48 2 } 49 1 50 1 if(TIM == Timer2) //Timer2,¹Ì¶¨Îª16λ×Ô¶¯ÖØ×°, ÖжÏÎÞÓÅÏȼ¶ 51 1 { 52 2 Timer2_Stop(); //Í£Ö¹¼ÆÊý C51 COMPILER V9.59.0.0 STC8A_TIMER 06/10/2021 10:10:14 PAGE 2 53 2 Timer2_CLK_Select(TIMx->TIM_ClkSource); //¶ÔÍâ¼ÆÊý»ò·ÖƵ, ¶¨Ê±12T/1T 54 2 Timer2_CLK_Output(TIMx->TIM_ClkOut); //Êä³öʱÖÓʹÄÜ 55 2 56 2 T2_Load(TIMx->TIM_Value); 57 2 Timer2_Run(TIMx->TIM_Run); 58 2 return SUCCESS; //³É¹¦ 59 2 } 60 1 61 1 if(TIM == Timer3) //Timer3,¹Ì¶¨Îª16λ×Ô¶¯ÖØ×°, ÖжÏÎÞÓÅÏȼ¶ 62 1 { 63 2 Timer3_Stop(); //Í£Ö¹¼ÆÊý 64 2 if(TIMx->TIM_ClkSource > TIM_CLOCK_Ext) return FAIL; 65 2 Timer3_CLK_Select(TIMx->TIM_ClkSource); //¶ÔÍâ¼ÆÊý»ò·ÖƵ, ¶¨Ê±12T/1T 66 2 Timer3_CLK_Output(TIMx->TIM_ClkOut); //Êä³öʱÖÓʹÄÜ 67 2 68 2 T3_Load(TIMx->TIM_Value); 69 2 Timer3_Run(TIMx->TIM_Run); 70 2 return SUCCESS; //³É¹¦ 71 2 } 72 1 73 1 if(TIM == Timer4) //Timer3,¹Ì¶¨Îª16λ×Ô¶¯ÖØ×°, ÖжÏÎÞÓÅÏȼ¶ 74 1 { 75 2 Timer4_Stop(); //Í£Ö¹¼ÆÊý 76 2 if(TIMx->TIM_ClkSource > TIM_CLOCK_Ext) return FAIL; 77 2 Timer4_CLK_Select(TIMx->TIM_ClkSource); //¶ÔÍâ¼ÆÊý»ò·ÖƵ, ¶¨Ê±12T/1T 78 2 Timer4_CLK_Output(TIMx->TIM_ClkOut); //Êä³öʱÖÓʹÄÜ 79 2 80 2 T4_Load(TIMx->TIM_Value); 81 2 Timer4_Run(TIMx->TIM_Run); 82 2 return SUCCESS; //³É¹¦ 83 2 } 84 1 return FAIL; //´íÎó 85 1 } MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 611 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = ---- ---- IDATA SIZE = ---- ---- BIT SIZE = ---- ---- EDATA SIZE = ---- ---- HDATA SIZE = ---- ---- XDATA CONST SIZE = ---- ---- FAR CONST SIZE = ---- ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)