1 ; C Compiler for STM8 (COSMIC Software) 2 ; Parser V4.8.32 - 23 Mar 2010 3 ; Generator V4.3.4 - 23 Mar 2010 2684 bsct 2685 0000 _version: 2686 0000 02 dc.b 2 2815 ; 24 void main() { 2817 switch .text 2818 0000 _main: 2820 0000 5206 subw sp,#6 2821 00000006 OFST: set 6 2824 ; 25 int i = 0,j=0; 2826 0002 5f clrw x 2827 0003 1f03 ldw (OFST-3,sp),x 2830 0005 5f clrw x 2831 0006 1f05 ldw (OFST-1,sp),x 2832 ; 26 CLK_CKDIVR = 0x08; //设置系统时钟为8MHZ 2834 0008 350850c6 mov _CLK_CKDIVR,#8 2835 ; 28 CLK_ICKR = 0x08; //打开低速时钟源 2837 000c 350850c0 mov _CLK_ICKR,#8 2838 ; 29 CFG_GCR |= 0x01; //禁止SWIM,复用PD1 2840 0010 72107f60 bset _CFG_GCR,#0 2841 ; 30 GPIO_INIT(); 2843 0014 cd0000 call _GPIO_INIT 2845 ; 47 IWDG_INIT(); 2847 0017 cd0000 call _IWDG_INIT 2849 ; 49 TIM1_PWM_INIT(); 2851 001a cd0000 call _TIM1_PWM_INIT 2853 ; 50 TIM4_INIT(); 2855 001d cd0000 call _TIM4_INIT 2857 ; 51 TIM2_INIT(); 2859 0020 cd0000 call _TIM2_INIT 2861 ; 52 ADC_INIT(); 2863 0023 cd0000 call _ADC_INIT 2865 ; 53 IIC_Init(); 2867 0026 cd0000 call _IIC_Init 2869 ; 54 _asm("rim"); //开总中断 2872 0029 9a rim 2874 ; 55 stm8_data.version = version; 2876 002a 450000 mov _stm8_data,_version 2877 ; 56 IIC_Init(); 2879 002d cd0000 call _IIC_Init 2882 0030 a605 ld a,#5 2883 0032 6b02 ld (OFST-4,sp),a 2884 0034 L3771: 2885 ; 57 INITTASKS(); //初始化任务函数 2887 0034 7b02 ld a,(OFST-4,sp) 2888 0036 5f clrw x 2889 0037 97 ld xl,a 2890 0038 58 sllw x 2891 0039 5a decw x 2892 003a 5a decw x 2893 003b 905f clrw y 2894 003d ef00 ldw (_timers,x),y 2897 003f 0a02 dec (OFST-4,sp) 2900 0041 0d02 tnz (OFST-4,sp) 2901 0043 26ef jrne L3771 2902 0045 L5002: 2903 ; 59 RUNTASK(safeTask,0); 2905 0045 be00 ldw x,_timers 2906 0047 2611 jrne L3202 2909 0049 cd0000 call _safeTask 2911 004c 1f01 ldw (OFST-5,sp),x 2913 004e 2004 jra L7102 2914 0050 L3102: 2917 0050 1e01 ldw x,(OFST-5,sp) 2918 0052 bf00 ldw _timers,x 2919 0054 L7102: 2922 0054 be00 ldw x,_timers 2923 0056 1301 cpw x,(OFST-5,sp) 2924 0058 26f6 jrne L3102 2925 005a L3202: 2926 ; 60 RUNTASK(safeIot,1); 2928 005a be02 ldw x,_timers+2 2929 005c 2611 jrne L1402 2932 005e cd0000 call _safeIot 2934 0061 1f01 ldw (OFST-5,sp),x 2936 0063 2004 jra L5302 2937 0065 L1302: 2940 0065 1e01 ldw x,(OFST-5,sp) 2941 0067 bf02 ldw _timers+2,x 2942 0069 L5302: 2945 0069 be02 ldw x,_timers+2 2946 006b 1301 cpw x,(OFST-5,sp) 2947 006d 26f6 jrne L1302 2948 006f L1402: 2949 ; 61 RUNTASK(getvbat,2); 2951 006f be04 ldw x,_timers+4 2952 0071 2611 jrne L7502 2955 0073 cd0000 call _getvbat 2957 0076 1f01 ldw (OFST-5,sp),x 2959 0078 2004 jra L3502 2960 007a L7402: 2963 007a 1e01 ldw x,(OFST-5,sp) 2964 007c bf04 ldw _timers+4,x 2965 007e L3502: 2968 007e be04 ldw x,_timers+4 2969 0080 1301 cpw x,(OFST-5,sp) 2970 0082 26f6 jrne L7402 2971 0084 L7502: 2972 ; 62 RUNTASK(control_task,3); 2974 0084 be06 ldw x,_timers+6 2975 0086 2611 jrne L5702 2978 0088 cd0000 call _control_task 2980 008b 1f01 ldw (OFST-5,sp),x 2982 008d 2004 jra L1702 2983 008f L5602: 2986 008f 1e01 ldw x,(OFST-5,sp) 2987 0091 bf06 ldw _timers+6,x 2988 0093 L1702: 2991 0093 be06 ldw x,_timers+6 2992 0095 1301 cpw x,(OFST-5,sp) 2993 0097 26f6 jrne L5602 2994 0099 L5702: 2995 ; 63 RUNTASK(fsl_task,4); 2997 0099 be08 ldw x,_timers+8 2998 009b 26a8 jrne L5002 3001 009d cd0000 call _fsl_task 3003 00a0 1f01 ldw (OFST-5,sp),x 3005 00a2 2004 jra L7012 3006 00a4 L3012: 3009 00a4 1e01 ldw x,(OFST-5,sp) 3010 00a6 bf08 ldw _timers+8,x 3011 00a8 L7012: 3014 00a8 be08 ldw x,_timers+8 3015 00aa 1301 cpw x,(OFST-5,sp) 3016 00ac 26f6 jrne L3012 3017 00ae 2095 jra L5002 3051 xdef _main 3052 xref.b _stm8_data 3053 xref _ADC_INIT 3054 xref _IIC_Init 3055 xref _GPIO_INIT 3056 xref _TIM4_INIT 3057 xref _TIM2_INIT 3058 xref _TIM1_PWM_INIT 3059 xref _fsl_task 3060 xref _control_task 3061 xref _getvbat 3062 xref _safeIot 3063 xref _safeTask 3064 xref _IWDG_INIT 3065 xdef _version 3066 switch .ubsct 3067 0000 _timers: 3068 0000 000000000000 ds.b 10 3069 xdef _timers 3089 end