中级会员
- 积分
- 361
- 威望
- 241
- 贡献
- 28
- 兑换币
- 0
- 注册时间
- 2008-12-19
- 在线时间
- 46 小时
|
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
#define R 30
#define L 66
#define R_0 68
#define L_0 60
unsigned char ccd[R][L];
unsigned int frm=0,nh;
unsigned int r,l;
unsigned int open,finish;
const unsigned int line_0[30]={26,30,34,38,43,
48,53,59,65,71,
78,85,92,110,118,
126,135,144,153,163,
173,183,194,205,216,
228,238,250,262,273
};
void Init(void){
SYNR = 0x04;
REFDV = 0x01;
while (CRGFLG&0x08==0);
CLKSEL = 0x80;
while (CLKSEL != 0x80)
CLKSEL = 0x80;
ATD0CTL3 = 0x08;
ATD0CTL4 = 0x80;
ATD0CTL2 = 0xC0;
ATD0CTL5 = 0xA5;
ATD0DIEN = 0xDF;
INTCR = 0xC0;
DDRM_DDRM4 = 0;
DDRA = 0x00;
DDRB = 0xFF;
}
//********************interrupt servicing program******************/
//********************interrupt servicing program******************/
#pragma CODE_SEG NON_BANKED
void interrupt 6 A_D(void){
if(frm^PTM_PTM4){
frm=PTM_PTM4;
nh =0;
r =0;
l =0;
open=1;
}
if(open==1){
if(nh==line_0[r]){
while(l<(L-1)){
while(!ATD0STAT1_CCF0);
ccd[r][l++]=ATD0DR0;
}
r++;
l=0;
}
if(r=R){
open=0;
finish=1;
}
nh++;
}
}
#pragma CODE_SEG DEFAULT
void main(void) {
Init();
EnableInterrupts;
for(;;) {
if(finish){
PORTB=0X81;
}
} /* wait forever */
/* please make sure that you never leave this function */
}
该程序能采到64个点,是我刚开始时写的,希望对你有用! |
|