test_on_bit_ok.c
来自「一个用单片机跟普通键盘的通信程序」· C语言 代码 · 共 65 行
C
65 行
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
unsigned char data[100];
unsigned char data_get=0;
unsigned char count=11;
unsigned char k=0;
void ect_init(void){
DDRT=0x00; //input
TSCR1=0x80; //enable timer
TIOS=0x00; //the correspond prot as input
TCTL4=0x08; /*channel 1 as capture on fall edge下沿*/
TSCR2=0x07; //div 128 for the bus clock
PACTL=0x00;
}
//TIE as the contcol of the intrrupt
void main(void) {
ect_init();
TIE=0x02; //start the intrrupt
DDRM=0x00;
EnableInterrupts;
PTM|=0x01;
count=0;
k=0;
while(1);
}
#pragma CODE_SEG NON_BANKED
void interrupt 9 data_in(void) {
TFLG1_C1F=1; //clear the flag
TIE=0x00;
data_get>>=1;
if(PTM&0x01){
data_get|=0x80;
data[k]=1;
}else
data[k]=0;
k++;
TIE=0x02;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?