//**************************************************************************** // @Module Project Settings // @Filename MAIN.C // @Project CL2.0.dav //---------------------------------------------------------------------------- // @Controller Infineon XC886CLM-8FF // // @Compiler Keil // // @Codegenerator 1.3 // // @Description This file contains the Project initialization function. // //---------------------------------------------------------------------------- // @Date 2025/1/18 20:45:29 // //**************************************************************************** // USER CODE BEGIN (MAIN_General,1) // USER CODE END //**************************************************************************** // @Project Includes //**************************************************************************** #include "MAIN.H" // USER CODE BEGIN (MAIN_General,2) // USER CODE END //**************************************************************************** // @Macros //**************************************************************************** // USER CODE BEGIN (MAIN_General,3) // USER CODE END //**************************************************************************** // @Defines //**************************************************************************** // USER CODE BEGIN (MAIN_General,4) // USER CODE END //**************************************************************************** // @Typedefs //**************************************************************************** // USER CODE BEGIN (MAIN_General,5) // USER CODE END //**************************************************************************** // @Imported Global Variables //**************************************************************************** // USER CODE BEGIN (MAIN_General,6) // USER CODE END //**************************************************************************** // @Global Variables //**************************************************************************** // USER CODE BEGIN (MAIN_General,7) // USER CODE END //**************************************************************************** // @External Prototypes //**************************************************************************** // USER CODE BEGIN (MAIN_General,8) // USER CODE END //**************************************************************************** // @Prototypes Of Local Functions //**************************************************************************** // USER CODE BEGIN (MAIN_General,9) // USER CODE END //**************************************************************************** // @Function void MAIN_vInit(void) // //---------------------------------------------------------------------------- // @Description This function initializes the microcontroller. It is // assumed that the SFRs are in their reset state. // //---------------------------------------------------------------------------- // @Returnvalue None // //---------------------------------------------------------------------------- // @Parameters None // //---------------------------------------------------------------------------- // @Date 2025/1/18 // //**************************************************************************** // USER CODE BEGIN (MAIN_Init,1) // USER CODE END void MAIN_vInit(void) { // USER CODE BEGIN (MAIN_Init,2) // USER CODE END /// ----------------------------------------------------------------------- /// Configuration of the System Clock: /// ----------------------------------------------------------------------- /// - External Osc is selected (configuration is done in the startup file /// 'START_XC.A51') /// - PLL Mode, NDIV = 24 /// - input frequency is 8 MHz // FCLK runs at 2 times the frequency of PCLK. SFR_PAGE(_su1, noSST); // switch to page1 CMCON = 0x10; // load Clock Control Register SFR_PAGE(_su0, noSST); // switch to page0 /// ********************************************************************************* /// Note : All peripheral related IO configurations are done in the /// respective peripheral modules (alternate functions selection) /// ********************************************************************************* /// Initialization of module 'GPIO' IO_vInit(); /// Initialization of module 'Timer 2' T2_vInit(); /// Initialization of module 'Watch Dog Timer' WDT_vInit(); /// Initialization of module 'Power Saving Modes' PS_vInit(); /// Initialization of module 'MultiCAN Controller ' CAN_vInit(); /// Initialization of 'Shared interrupts' SHINT_vInit(); // Interrupt Priority IP = 0x00; // load Interrupt Priority Register IPH = 0x00; // load Interrupt Priority High Register IP1 = 0x00; // load Interrupt Priority 1 Register IPH1 = 0x00; // load Interrupt Priority 1 High Register // USER CODE BEGIN (MAIN_Init,3) // USER CODE END //// Interrupt structure 2 mode 0 is selected. //// Interrupt service routine choice 2 is selected. // globally enable interrupts EA = 1; } // End of function MAIN_vInit //**************************************************************************** // @Function void main(void) // //---------------------------------------------------------------------------- // @Description This is the main function. // //---------------------------------------------------------------------------- // @Returnvalue None // //---------------------------------------------------------------------------- // @Parameters None // //---------------------------------------------------------------------------- // @Date 2025/1/18 // //**************************************************************************** // USER CODE BEGIN (MAIN_Main,1) // USER CODE END void main(void) { // USER CODE BEGIN (MAIN_Main,2) // ulong i,j; // static ubyte tmp[8] = {0}; // for(j=0;j<200;j++){for(i=0;i<133;i++);} // USER CODE END MAIN_vInit(); // USER CODE BEGIN (MAIN_Main,3) SCU_PAGE = 0; SP = 0xC0; // Initialize Stack Pointer to 0xC0; // CanTransmit(); // BM8563_InitTime(); // BM8563_Set4HourAlarm();// KGF_PIN = 1;//KGF唤醒 BATTERY_PIN = 1; SetConfig(CFG_MPS_Single,CFG_Repeatbility_High); // FlgCan_1 = 1;//复位后延时一段时间再调用CAN发送 // USER CODE END // SetConfig(1,CFG_MPS_Single,CFG_Repeatbility_High); RomNum = Search_ROM(romid); //搜索当前总线上的所有芯片,将ROM ID存入数组romid,并返回芯片个数 while(1) { // USER CODE BEGIN (MAIN_Main,4) // for(j=0;j<200;j++){for(i=0;i<133;i++)WDT_vRefresh();} // tmp[3] = (ubyte)CntCan_1; // tmp[2] = (ubyte)(CntCan_1>>8); // SwSample(); CanRXTX(); CanErrorProcess(); WDT_vRefresh(); // LedDr(); BootMain(); // tmp[1] = (ubyte)CntCan_1; // tmp[0] = (ubyte)(CntCan_1>>8); // CAN_vLoadData(0x2, (ulong *)(tmp)); // Add this Line // CAN_vTransmit(2); // for(j=0;j<200;j++){for(i=0;i<133;i++)WDT_vRefresh();} // USER CODE END } } // End of function main // USER CODE BEGIN (MAIN_General,10) // USER CODE END