河北联合程序.docx

上传人:b****8 文档编号:30533114 上传时间:2023-08-16 格式:DOCX 页数:62 大小:24.64KB
下载 相关 举报
河北联合程序.docx_第1页
第1页 / 共62页
河北联合程序.docx_第2页
第2页 / 共62页
河北联合程序.docx_第3页
第3页 / 共62页
河北联合程序.docx_第4页
第4页 / 共62页
河北联合程序.docx_第5页
第5页 / 共62页
点击查看更多>>
下载资源
资源描述

河北联合程序.docx

《河北联合程序.docx》由会员分享,可在线阅读,更多相关《河北联合程序.docx(62页珍藏版)》请在冰豆网上搜索。

河北联合程序.docx

河北联合程序

//*Includingneededmodulestocompilethismodule/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.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"

/*Includingsharedmodules,whichareusedforwholeproject*/

#include"PE_Types.h"

#include"PE_Error.h"

#include"PE_Const.h"

#include"IO_Map.h"

#defineres(a)res_5110_PutVal(a)

#definesce(a)sce_5110_PutVal(a)

#definedc(a)dc_5110_PutVal(a)

#definesdin(a)sdin_5110_PutVal(a)

#definesclk(a)sclk_5110_PutVal(a)

/*Globalvariables*/

volatilewordSR_lock=0;/*Lock*/

volatilewordSR_reg;/*CurrentvalueoftheSRregister*/

/*

**===================================================================

**Method:

Cpu_Interrupt(component56F8366)

**

**Description:

**Themethodservicesunhandledinterruptvectors.

**Thismethodisinternal.ItisusedbyProcessorExpertonly.

**===================================================================

*/

#pragmainterruptalignsp

voidCpu_Interrupt(void)

{

asm(DEBUGHLT);/*Haltthecoreandplacingitinthedebugprocessingstate*/

}

/*lint-save-e?

?

?

?

DisableMISRArule(all)checking.*/

asmvoidCpu_Delay100US(wordus100)

{

/*Totalirremovableoverhead:

about16cycles*/

/*move.w:

2cyclesoverhead(loadparameterintoregister)*/

/*jsr:

5cyclesoverhead(jumptosubroutine)*/

/*rts:

8cyclesoverhead(returnfromsubroutine)*/

/*nop:

1cyclesoverhead(aditionalnops)*/

loop:

/*100usdelayblockbegin*/

/*

*Delay

*-requested:

100us@100MHz,

*-possible:

10000c,100000ns

*-withoutremovableoverhead:

9994c,99940ns

*/

adda#2,SP/*(1c:

10ns)moveSPforward*/

move.lA10,X:

(SP)/*(2c:

20ns)pushA*/

move.w#4989,A/*(2c:

20ns)numberofiterations*/

doA,label0/*(8c:

80ns)repeat4989xnop*/

nop/*(1c:

10ns)waitfor1c*/

label0:

move.lX:

(SP),A/*(2c:

20ns)popA*/

suba#2,SP/*(1c:

10ns)moveSPback*/

/*100usdelayblockend*/

dec.wY0/*us100parameterispassedviaY0register*/

jneloop/*nextloop*/

nop/*avoidpipelineconflicts*/

rts/*returnfromsubroutine*/

}

/*lint-restore*/

/*

**===================================================================

**Method:

Cpu_DisableInt(component56F8366)

**

**Description:

**Disablesallmaskableinterrupts

**Parameters:

None

**Returns:

Nothing

**===================================================================

*/

/*

voidCpu_DisableInt(void)

**Thismethodisimplementedasmacrointheheadermodule.**

*/

/*

**===================================================================

**Method:

Cpu_EnableInt(component56F8366)

**

**Description:

**Enablesallmaskableinterrupts

**Parameters:

None

**Returns:

Nothing

**===================================================================

*/

/*

voidCpu_EnableInt(void)

**Thismethodisimplementedasmacrointheheadermodule.**

*/

/*

**===================================================================

**Method:

Cpu_SetStopMode(component56F8366)

**

**Description:

**Setslowpowermode-Stopmode.

**FormoreinformationaboutthestopmodeseethisCPU

**documentation.

**Parameters:

None

**Returns:

Nothing

**===================================================================

*/

/*

voidCpu_SetStopMode(void)

**Thismethodisimplementedasmacrointheheadermodule.**

*/

/*

**===================================================================

**Method:

Cpu_SetWaitMode(component56F8366)

**

**Description:

**Setslowpowermode-Waitmode.

**FormoreinformationaboutthewaitmodeseethisCPU

**documentation.

**Releasefromwaitmode:

Resetorinterrupt

**Parameters:

None

**Returns:

Nothing

**===================================================================

*/

/*

voidCpu_SetWaitMode(void)

**Thismethodisimplementedasmacrointheheadermodule.**

*/

/*

**===================================================================

**Method:

Cpu_SetDataMode(component56F8366)

**

**Description:

**SetstheDatamemorymaptouseeitherinternal&

**externalresourcesorexternalresourcesonly.

**Parameters:

**NAME-DESCRIPTION

**Mode-Datamemoryaccessmode.

**Possiblemodes:

**INT_EXT_MODE-useinternal&external

**resources

**EXT_MODE-useexternalresourcesonly

**Returns:

Nothing

**===================================================================

*/

voidCpu_SetDataMode(byteMode)

{

if(Mode==INT_EXT_MODE){

asm{bfclr#0x0008,OMR}/*Setinternalandexternaldatamemorymode*/

}else{

asm{bfset#0x0008,OMR}/*Setexternaldatamemorymode*/

}

}

/*

**===================================================================

**Method:

_EntryPoint(component56F8366)

**

**Description:

**Initializesthewholesystemliketimingandsoon.Attheend

**ofthisfunction,theCstartupisinvokedtoinitializestack,

**memoryareasandsoon.

**Thismethodisinternal.ItisusedbyProcessorExpertonly.

**===================================================================

*/

externvoidinit_56800_(void);/*Forwarddeclarationofexternalstartupfunction

declaredinstartupfile*/

/***!

!

!

Hereyoucanplaceyourowncodeusingproperty"Userdatadeclarations"

onthebuildoptionstab.!

!

!

***/

void_EntryPoint(void)

{

#pragmaconstarrayoff

/***!

!

!

HereyoucanplaceyourowncodebeforePEinitializationusingproperty

"UsercodebeforePEinitialization"onthebuildoptionstab.!

!

!

***/

/***###56F8366"Cpu"initcode...***/

/***PEinitializationcodeafterreset***/

/*Systemclockinitialization*/

setReg(PLLCR,(PLLCR_LCKON_MASK|PLLCR_ZSRC0_MASK));/*EnablePLL,LCKONand

selectclocksourcefromprescaler*/

/*PLLDB:

LORTP=2,PLLCOD=0,PLLCID=1,?

?

=0,PLLDB=99*/

setReg16(PLLDB,8547U);/*Settheclockprescalers*/

while(!

getRegBit(PLLSR,LCK0)){}/*WaitforPLLlock*/

setReg(PLLCR,(PLLCR_LCKON_MASK|PLLCR_ZSRC1_MASK));/*Selectclocksource

frompostscaler*/

/*FMCLKD:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,DIVLD=0,PRDIV8=1,DIV=31*/

setReg16(FMCLKD,95U);/*Settheflashclockprescaler*/

/***EndofPEinitializationcodeafterreset***/

/***!

!

!

HereyoucanplaceyourowncodeafterPEinitializationusingproperty

"UsercodeafterPEinitialization"onthebuildoptionstab.!

!

!

***/

asm(JMPinit_56800_);/*JumptoCstartupcode*/

}

/*

**===================================================================

**Method:

PE_low_level_init(component56F8366)

**

**Description:

**Initializesbeansandprovidescommonregisterinitialization.

**Themethodiscalledautomaticallyasapartofthe

**applicationinitializationcode.

**Thismethodisinternal.ItisusedbyProcessorExpertonly.

**===================================================================

*/

voidPE_low_level_init(void)

{

/*DEC0_FIR:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,DELAY=0*/

setReg16(DEC0_FIR,0U);/*SetupFilterIntervalRegisterofQuadratureDecoder

0*/

/*DEC1_FIR:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,DELAY=0*/

setReg16(DEC1_FIR,0U);/*SetupFilterIntervalRegisterofQuadratureDecoder

1*/

/*SIM_PCE:

EMI=1,ADC_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,S

CI_1=1,SCI_0=1,SPI_1=1,SPI_0=1,PWM_B=1,PWM_A=1*/

setReg16(SIM_PCE,65535U);/*Setuptheperipheralclockenableregister*/

/*SIM_PCE2:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,CA

N2=1*/

setReg16(SIM_PCE2,1U);/*Setuptheperipheralclockenableregister*/

/*SIM_CONTROL:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,emi_mode=0,OnceEbl=0,SWRst=0,sto

p_disable=0,wait_disable=0*/

setReg16(SIM_CONTROL,0U);/*SetuptheSIMcontrolregister*/

/*SIM_CLKOSR:

?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,?

?

=0,A23_b=0,A22_b=0,A21_b=0,A20_b=0,CLKDIS=1,CLKOSE

L=0*/

setReg16(SIM_CLKOSR,32U);/*SetuptheSIMclockoutputselectregister*/

/*TSENSOR_CONTROL:

PWR=0*/

clrReg16Bits(TSENSOR_CONTROL,1U);/*Disablepowersourceforthetemperature

sensor*/

/*CommoninitializationoftheCPUregisters*/

/*GPIO_E_PER:

PE10=1,PE8=1,PE3=0,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=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