中级会员
- 积分
- 462
- 威望
- 259
- 贡献
- 131
- 兑换币
- 141
- 注册时间
- 2015-3-9
- 在线时间
- 36 小时
- 毕业学校
- 阜阳师范学院
|
void PortInit(void) //端口初始化
{ // 1 为输出 0 为输入
DDRB = 0x00; //端口B方向为输入
DDRM = 0XFF; //低四位为输入
PTM = 0x00;
/*------------------------------
ccd initialization
------------------------------ */
DDRA_DDRA7 = 1; //CCD1CLK
DDRA_DDRA5 = 1; //CCD1SI
PORTA_PA7 = 0; //CCD1CLK
PORTA_PA5 = 0; //CCD1SI
}
void ATD_Init(void) //AD初始化
{
ATD0CTL0 = 0x07; //返转通道设定为AN7
ATD0CTL1 = 0x40; //7-外部触发,65:10-12位精度,4:不放电,3210:ch0 40
ATD0CTL2 = 0x40; //禁止外部触发, 中断禁止
ATD0CTL3 = 0xc0; //a右对齐无符号,每次转换7个序列, No FIFO, Freeze模式下继续转
ATD0CTL4 = 0x09; //765:采样时间为4个AD时钟周期,ATDClock=[BusClock*0.5]/[PRS+1] //转换时间 1.6us
ATD0CTL5 = 0x30; //6:0特殊通道禁止,5:1连续转换 ,4:1多通道轮流采样
ATD0DIEN = 0x00; //禁止数字输
}
void ImageCapture(unsigned char * ImageData) {
unsigned char i;
TSL1401_SI=1; /* SI = 1 */
SamplingDelay();
TSL1401_CLK=1; /* CLK = 1 */
SamplingDelay();
TSL1401_SI=0; /* SI = 0 */
SamplingDelay();
//Delay 10us for sample the first pixel
for(i = 0; i < 10; i++) {
Cpu_Delay1us();
}
//Sampling Pixel 1
*ImageData = (byte)( Read_ADValue(5));
*ImageData++ ;
TSL1401_CLK=0; /* CLK = 0 */
for(i=0; i<127; i++) {
SamplingDelay();
SamplingDelay();
TSL1401_CLK=1; /* CLK = 1 */
SamplingDelay();
SamplingDelay();
//Sampling Pixel 2~128
*ImageData = (byte)( Read_ADValue(5));
*ImageData++ ;
TSL1401_CLK=0; /* CLK = 0 */
}
SamplingDelay();
SamplingDelay();
TSL1401_CLK=1; /* CLK = 1 */
SamplingDelay();
SamplingDelay();
TSL1401_CLK=0; /* CLK = 0 */
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|