📄 hardwareinit.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void HardwareInit(void) {
DisableInterrupts;
// CLOCK Initialize
REFDV=1;
SYNR=2;
asm{
BRCLR CRGFLG,#$08,*
}
CLKSEL=0x80;
// SCI Initialize
SCI0CR2=0x0C;
SCI0BD=0x009C; //波特率9600
//SCI0BD=0x000D; //波特率115200
// PORT Initialize
PORTB=0xFF;
DDRB=0xFF;
DDRK=0xF0;
// PWM Initialize
PWMCTL=0x70; //01,23,45 combine
PWMPRCLK=0x33; //All The Prescale Clocks = 24MHz/8 =3MHz
PWMCLK=0x00; //Select A/B For All Channels
PWMPOL=0xFF; //
PWMPER23=495;
PWMPER45=495;
PWMDTY23=0;
PWMDTY45=0;
PWMPER01=60000;
PWMDTY01=4500;
PWME=0x3F;
// ECT Initialize
/*TIOS=0x0F;
TIE=0;
TSCR2=3;
TCTL3=0x40;
TSCR1=0x81;*/
// ADT Initialize
ATD0CTL2=0x00;
ATD0CTL3=8;
ATD0CTL4=0xC5;
ATD0DIEN=0;
ATD1CTL2=0x00;
ATD1CTL3=8;
ATD1CTL4=0xC5;
ATD1DIEN=0;
INTCR=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -