1、河北联合程序/* Including needed modules to compile this module/procedure */ #include Cpu.h #include Events.h #include sci0.h #include io_b0.h #include hs_interrupt.h #include vs_interrupt.h #include res_5110.h #include sce_5110.h #include dc_5110.h #include sdin_5110.h #include sclk_5110.h #include bmq_js
2、.h #include dianji.h #include duoji.h #include dianji_io0.h #include dianji_io1.h #include k1.h #include k2.h #include k3.h #include k4.h #include k5.h #include k6.h #include buzzer.h #include Bit1.h #include Bit2.h #include key_low.h #include key_high.h /* Including shared modules, which are used f
3、or whole project */ #include PE_Types.h #include PE_Error.h #include PE_Const.h #include IO_Map.h #define res(a) res_5110_PutVal(a) #define sce(a) sce_5110_PutVal(a) #define dc(a) dc_5110_PutVal(a) #define sdin(a) sdin_5110_PutVal(a) #define sclk(a) sclk_5110_PutVal(a) /* Global variables */ volatil
4、e word SR_lock = 0; /* Lock */ volatile word SR_reg; /* Current value of the SR register */ /* * = * Method : Cpu_Interrupt (component 56F8366) * * Description : * The method services unhandled interrupt vectors. * This method is internal. It is used by Processor Expert only. * = */ #pragma interrup
5、t alignsp void Cpu_Interrupt(void) asm(DEBUGHLT); /* Halt the core and placing it in the debug processing state */ /*lint -save -e? Disable MISRA rule (all) checking. */ asm void Cpu_Delay100US(word us100) /* Total irremovable overhead: about 16 cycles */ /* move.w: 2 cycles overhead (load parameter
6、 into register) */ /* jsr: 5 cycles overhead (jump to subroutine) */ /* rts: 8 cycles overhead (return from subroutine) */ /* nop: 1 cycles overhead (aditional nops) */ loop: /* 100 us delay block begin */ /* * Delay * - requested : 100 us 100MHz, * - possible : 10000 c, 100000 ns * - without remova
7、ble overhead : 9994 c, 99940 ns */ adda #2, SP /* (1 c: 10 ns) move SP forward */ move.l A10, X:(SP) /* (2 c: 20 ns) push A */ move.w #4989, A /* (2 c: 20 ns) number of iterations */ do A, label0 /* (8 c: 80 ns) repeat 4989x nop */ nop /* (1 c: 10 ns) wait for 1 c */ label0: move.l X:(SP), A /* (2 c
8、: 20 ns) pop A */ suba #2, SP /* (1 c: 10 ns) move SP back */ /* 100 us delay block end */ dec.w Y0 /* us100 parameter is passed via Y0 register */ jne loop /* next loop */ nop /* avoid pipeline conflicts */ rts /* return from subroutine */ /*lint -restore */ /* * = * Method : Cpu_DisableInt (compon
9、ent 56F8366) * * Description : * Disables all maskable interrupts * Parameters : None * Returns : Nothing * = */ /* void Cpu_DisableInt(void) * This method is implemented as macro in the header module. * */ /* * = * Method : Cpu_EnableInt (component 56F8366) * * Description : * Enables all maskable
10、interrupts * Parameters : None * Returns : Nothing * = */ /* void Cpu_EnableInt(void) * This method is implemented as macro in the header module. * */ /* * = * Method : Cpu_SetStopMode (component 56F8366) * * Description : * Sets low power mode - Stop mode. * For more information about the stop mode
11、 see this CPU * documentation. * Parameters : None * Returns : Nothing * = */ /* void Cpu_SetStopMode(void) * This method is implemented as macro in the header module. * */ /* * = * Method : Cpu_SetWaitMode (component 56F8366) * * Description : * Sets low power mode - Wait mode. * For more informati
12、on about the wait mode see this CPU * documentation. * Release from wait mode: Reset or interrupt * Parameters : None * Returns : Nothing * = */ /* void Cpu_SetWaitMode(void) * This method is implemented as macro in the header module. * */ /* * = * Method : Cpu_SetDataMode (component 56F8366) * * De
13、scription : * Sets the Data memory map to use either internal & * external resources or external resources only. * Parameters : * NAME - DESCRIPTION * Mode - Data memory access mode. * Possible modes: * INT_EXT_MODE - use internal & external * resources * EXT_MODE - use external resources only * Ret
14、urns : Nothing * = */ void Cpu_SetDataMode(byte Mode) if (Mode = INT_EXT_MODE) asm bfclr #0x0008,OMR /* Set internal and external data memory mode */ else asm bfset #0x0008,OMR /* Set external data memory mode */ /* * = * Method : _EntryPoint (component 56F8366) * * Description : * Initializes the w
15、hole system like timing and so on. At the end * of this function, the C startup is invoked to initialize stack, * memory areas and so on. * This method is internal. It is used by Processor Expert only. * = */ extern void init_56800_(void); /* Forward declaration of external startup function declared
16、 in startup file */ /* ! Here you can place your own code using property User data declarations on the build options tab. ! */ void _EntryPoint(void) #pragma constarray off /* ! Here you can place your own code before PE initialization using property User code before PE initialization on the build o
17、ptions tab. ! */ /* # 56F8366 Cpu init code . */ /* PE initialization code after reset */ /* System clock initialization */ setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC0_MASK); /* Enable PLL, LCKON and select clock source from prescaler */ /* PLLDB: LORTP=2,PLLCOD=0,PLLCID=1,?=0,PLLDB=99 */ setReg16
18、(PLLDB, 8547U); /* Set the clock prescalers */ while(!getRegBit(PLLSR, LCK0) /* Wait for PLL lock */ setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC1_MASK); /* Select clock source from postscaler */ /* FMCLKD: ?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,DIVLD=0,PRDIV8=1,DIV=31 */ setReg16(FMCLKD, 95U); /* Set the
19、flash clock prescaler */ /* End of PE initialization code after reset */ /* ! Here you can place your own code after PE initialization using property User code after PE initialization on the build options tab. ! */ asm(JMP init_56800_); /* Jump to C startup code */ /* * = * Method : PE_low_level_ini
20、t (component 56F8366) * * Description : * Initializes beans and provides common register initialization. * The method is called automatically as a part of the * application initialization code. * This method is internal. It is used by Processor Expert only. * = */ void PE_low_level_init(void) /* DEC
21、0_FIR: ?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,DELAY=0 */ setReg16(DEC0_FIR, 0U); /* Set up Filter Interval Register of Quadrature Decoder 0 */ /* DEC1_FIR: ?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,DELAY=0 */ setReg16(DEC1_FIR, 0U); /* Set up Filter Interval Register of Quadrature Decoder 1 */ /* SIM_PCE: EMI=1,ADC_
22、B=1,ADC_A=1,CAN=1,DEC_1=1,DEC_0=1,TMR_D=1,TMR_C=1,TMR_B=1,TMR_A=1,SCI_1=1,SCI_0=1,SPI_1=1,SPI_0=1,PWM_B=1,PWM_A=1 */ setReg16(SIM_PCE, 65535U); /* Set up the peripheral clock enable register */ /* SIM_PCE2: ?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,CAN2=1 */ setReg16(SIM_PCE2, 1U);
23、 /* Set up the peripheral clock enable register */ /* SIM_CONTROL: ?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,?=0,emi_mode=0,OnceEbl=0,SWRst=0,stop_disable=0,wait_disable=0 */ setReg16(SIM_CONTROL, 0U); /* Set up the SIM control register */ /* SIM_CLKOSR: ?=0,?=0,?=0,?=0,?=0,?=0,A23_b=0,A22_b=0,A21_b=0,A20_b=0
24、,CLKDIS=1,CLKOSEL=0 */ setReg16(SIM_CLKOSR, 32U); /* Set up the SIM clock output select register */ /* TSENSOR_CONTROL: PWR=0 */ clrReg16Bits(TSENSOR_CONTROL, 1U); /* Disable power source for the temperature sensor */ /* Common initialization of the CPU registers */ /* GPIO_E_PER: PE10=1,PE8=1,PE3=0
25、,PE2=0,PE1=1,PE0=1 */ clrSetReg16Bits(GPIO_E_PER, 12U, 1283U); /* GPIO_B_PUR: PU=1 */ setReg16Bits(GPIO_B_PUR, 1U); /* GPIO_B_PPMODE: PPMODE=1 */ setReg16Bits(GPIO_B_PPMODE, 1U); /* GPIO_B_DR: D=0 */ clrReg16Bits(GPIO_B_DR, 1U); /* GPIO_B_DDR: DD=0 */ clrReg16Bits(GPIO_B_DDR, 1U); /* GPIO_B_PER: PE=
26、0 */ clrReg16Bits(GPIO_B_PER, 1U); /* GPIO_B_IPOLR: IPOL=0 */ clrReg16Bits(GPIO_B_IPOLR, 1U); /* GPIO_B_IENR: IEN=0 */ clrReg16Bits(GPIO_B_IENR, 1U); /* INTC_IPR6: TMRC_0_IPL=2,TMRD_0_IPL=2 */ clrSetReg16Bits(INTC_IPR6, 16448U, 32896U); /* GPIO_E_PUR: PU10=1,PU8=1 */ setReg16Bits(GPIO_E_PUR, 1280U); /* GPIO_A_IENR: IEN&=255 */ clrReg16Bits(GPIO_A_IENR, 255U); /* GPIO_A_IAR: IA&=255 */ clrReg16Bits(GPIO_A_IAR, 255U);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1