📄 mcuinit.c
字号:
/*
** ###################################################################
** This code is generated by the Device Initialization Tool.
** It is overwritten during code generation.
** USER MODIFICATION ARE PRESERVED ONLY INSIDE INTERRUPT SERVICE ROUTINES
**
** Project : E3________
** Processor : MC68HC908JL16CFJE
** Version : Bean 01.046, Driver 01.00, CPU db: 2.87.077
** Datasheet : MC68HC908JL16 Rev. 1.1 11/2005
** Date/Time : 2007-10-16, 20:39
** Abstract :
** This bean "MC68HC908JL16_32FA" provides initialization of the
** CPU core and shared peripherals.
** Settings :
** Clock setting
** External clock : 9.8304 MHz
** CPU mode selection : 1
** Initialization interrupt priority : 1
** Stop instruction enabled : no
** LVI module : yes
**
** Source clock : Main clock frequency / 1
** Internal bus clock : 2.4576 MHz
** Contents :
** Function "MCU_init" initializes selected peripherals
**
** (c) Copyright UNIS, spol. s r.o. 1997-2006
** UNIS, spol s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################
*/
#include <MC68HC908JL16.h> /* I/O map for MC68HC908JL16CFJE */
#include "24c02.h"
#define Dir_Receive PTE&=~PTE_PTE1_MASK;PTE|=PTE_PTE0_MASK
#define Dir_Transmit PTE|=PTE_PTE1_MASK;PTE&=~PTE_PTE0_MASK
extern unsigned char j;
extern unsigned char p;
extern unsigned int shuju;
extern unsigned int b;
extern unsigned char q;
extern unsigned char date5[3];
#define CGM_DELAY 0x27FFUL
/*
** ===================================================================
** Method : MCU_init (bean MC68HC908JL16_32FA)
**
** Description :
** Device initialization code for selected peripherals.
** ===================================================================
*/
void MCU_init(void)
{
/*** ### MC68HC908JL16_32FA "Cpu" init code ... ***/
/*** PE initialization code after reset ***/
/* System clock initialization */
/* Common initialization of the write once registers */
/* CONFIG1: COPRS=0,LVID=0,SSREC=0,STOP=0,COPD=1 */
CONFIG1 = 0x01;
/* CONFIG2: IRQPUD=0,LVIT1=1,LVIT0=0,IICSEL=0,STOP_ICLKDIS=0 */
CONFIG2 = 0x10;
/* Common initialization of the CPU registers */
/* ### Init_GPIO init code */
/* DDRA: DDRA4=0 */
DDRA &= (unsigned char)~0x10;
/* ### Init_GPIO init code */
/* PTB: PTB7=0,PTB6=0,PTB5=0,PTB4=0,PTB3=0,PTB2=0,PTB1=0,PTB0=0 */
PTB = 0x00;
/* DDRB: DDRB7=1,DDRB6=1,DDRB5=1,DDRB4=1,DDRB3=1,DDRB2=1,DDRB1=1,DDRB0=1 */
DDRB = 0xFF;
/* ### Init_GPIO init code */
/* PTD: PTD4=0,PTD1=0 */
PTD &= (unsigned char)~0x12;
/* DDRD: DDRD4=1,DDRD1=1 */
DDRD |= (unsigned char)0x12;
/* ### Init_TIM init code */
/* T1SC: TOF=0,TOIE=0,TSTOP=1,TRST=1,PS2=0,PS1=0,PS0=0 */
T1SC = 0x30; /* Stop and reset counter */
T1MOD = 0x95FF; /* Period value setting */
(void)(T1SC == 0); /* Overflow int. flag clearing (first part) */
/* T1SC: TOF=0,TOIE=1,TSTOP=0,TRST=0,PS2=1,PS1=1,PS0=0 */
T1SC = 0x46; /* Int. flag clearing (2nd part) and timer contr. register setting */
/* ### Init_ADC init code */
/* ADCLK: ADLPC=0,ADIV1=1,ADIV0=1,ADICLK=0,MODE1=0,MODE0=1,ADLSMP=1,ACLKEN=0 */
ADCLK = 0x62;
/* ADCSC: COCO=0,AIEN=1,ADCO=0,ADCH4=0,ADCH3=1,ADCH2=0,ADCH1=0,ADCH0=1 */
ADCSC = 0x49;
/* ### Init_TIM init code */
/* T2SC: TOF=0,TOIE=0,TSTOP=1,TRST=1,PS2=0,PS1=0,PS0=0 */
T2SC = 0x30; /* Stop and reset counter */
T2MOD = 0xFFFF; /* Period value setting */
(void)(T2SC == 0); /* Overflow int. flag clearing (first part) */
/* T2SC: TOF=0,TOIE=1,TSTOP=0,TRST=0,PS2=1,PS1=1,PS0=0 */
T2SC = 0x46; /* Int. flag clearing (2nd part) and timer contr. register setting */
/* ### Init_SCI init code */
/* SCC1: LOOPS=0,ENSCI=0,TXINV=0,M=0,WAKE=0,ILTY=0,PEN=0,PTY=0 */
SCC1 = 0x00; /* Disable the SCI module */
(void)(SCS1 == 0); /* Dummy read of the SCS1 registr to clear flags */
(void)(SCS2 == 0); /* Dummy read of the SCS2 registr to clear flags */
(void)(SCDR == 0); /* Dummy read of the SCDR registr to clear flags */
/* SCC3: R8=0,T8=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */
SCC3 = 0x00;
/* SCBR: SCP1=1,SCP0=0,SCR2=0,SCR1=0,SCR0=0 */
SCBR = 0x20;
/* SCC1: LOOPS=0,ENSCI=1,TXINV=0,M=1,WAKE=1,ILTY=1,PEN=0,PTY=0 */
SCC1 = 0x5C;
/* SCC2: SCTIE=0,TCIE=0,SCRIE=1,ILIE=0,TE=1,RE=1,RWU=1,SBK=0 */
SCC2 = 0x2E;
/* ### Init_GPIO init code */
/* PTE: PTE1=0,PTE0=1 */
PTE = (PTE & (unsigned char)~0x02) | (unsigned char)0x01;//初始化PTE端口,把184的状态设置为接收数据状态
/* DDRE: DDRE1=1,DDRE0=1 */
DDRE |= (unsigned char)0x03;//初始化PTE端口,把184的状态设置为接收数据状态
/* ### */
asm CLI; /* Enable interrupts */
} /*MCU_init*/
/*
** ===================================================================
** Interrupt handler : isrINT_ADC
**
** Description :
** User interrupt service routine.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
__interrupt void isrINT_ADC(void)
{
/* Write your interrupt code here ... */
ADCSC_COCO=0;
}
/* end of isrINT_ADC */
/*
** ===================================================================
** Interrupt handler : isrINT_SCITransmit
**
** Description :
** User interrupt service routine.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
__interrupt void isrINT_SCITransmit(void)//transmitter
{
/* Write your interrupt code here ... */
__asm SEI;
if(SCS1_SCTE) //SCS1_SCTE为1时,启动SCI通信传送位空,发送中断?如果发送寄存器空
{
SCC2&=~SCC2_SCTIE_MASK;//SCC2:SCI寄存器控制器2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -