摄像头 程序Word文件下载.docx

上传人:b****6 文档编号:20822323 上传时间:2023-01-25 格式:DOCX 页数:11 大小:18.18KB
下载 相关 举报
摄像头 程序Word文件下载.docx_第1页
第1页 / 共11页
摄像头 程序Word文件下载.docx_第2页
第2页 / 共11页
摄像头 程序Word文件下载.docx_第3页
第3页 / 共11页
摄像头 程序Word文件下载.docx_第4页
第4页 / 共11页
摄像头 程序Word文件下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

摄像头 程序Word文件下载.docx

《摄像头 程序Word文件下载.docx》由会员分享,可在线阅读,更多相关《摄像头 程序Word文件下载.docx(11页珍藏版)》请在冰豆网上搜索。

摄像头 程序Word文件下载.docx

bytecount,second;

voidDelay(intDe_a)

{

intDe_b;

for(De_b=0;

De_b<

De_a;

De_b++)

{

_asm(nop);

//_asm(nop);

}

}

/***********************************************************************/

voidcrg_init(void)

{

CLKSEL=0x00;

//脱离锁相环

PLLCTL_PLLON=1;

//打开锁相环

SYNR=0XC0|0X09;

//SYNR=3,REFDV=1

REFDV=0X80|0X01;

//pllclock=2*16*(1+SYNR)/(1+REFDV)=96MHz;

POSTDIV=0X00;

//锁相环时钟为96MHz

while(0==CRGFLG_LOCK);

//锁相环锁定

CLKSEL_PLLSEL=1;

voidPWM_Init(void)

PWME=0X00;

//禁止通道

PWMPRCLK=0X33;

//A=B=80/8=10MHZ

PWMSCLA=5;

//SA=A/2/5=1MHZ

PWMSCLB=5;

//SB=B/2/5=1MHZ

/*PWM0,1级联初始化*/

PWMCTL_CON01=1;

//0,1级联,寄存器为通道1的

PWMCLK_PCLK1=1;

//选时钟SB

PWMPOL_PPOL1=1;

//初始电平为高

PWMCAE_CAE1=0;

//左对齐方式

PWMCNT01=0;

//计数器清零

PWMPER01=20000;

//输出周期=SB/10000=100HZ

PWMDTY01=1580;

//舵机静止占空比为7.5%=1500/20000

PWME_PWME1=1;

//使能

 

PWMCTL_CON23=1;

PWMCLK_PCLK3=0;

PWMPOL_PPOL3=1;

PWMCAE_CAE3=0;

PWMCNT23=0;

PWMPER23=600;

PWMDTY23=0;

PWME_PWME3=1;

PWMCTL_CON45=1;

PWMCLK_PCLK5=0;

PWMPOL_PPOL5=1;

PWMCAE_CAE5=0;

PWMCNT45=0;

PWMPER45=0;

PWMDTY45=500;

PWME_PWME5=1;

/*舵机控制*/

voidPWMDuo_Dutycycle(inta)

PWMDTY01=a;

voidPWMDian_Dutycycle(intb)

PWMDTY45=b;

}

/******************************************************************

-功能描述:

T0接受行中断,上升沿触发,T1接受场中断,下降沿触发,T7计数

-参数说明:

-返回说明:

-修改记录:

-注意事项:

总线时钟为40M时,该程序适用。

******************************************************************/

voidect_init()

TIOS=0x00;

//T0、T1设置为输入捕捉,摄像头行场中断---关输出比较通道7

TCTL4=0x09;

//通道0为上升沿捕捉,1为下降沿捕捉

TIE=0x03;

//开场中断,行中断

TSCR1=0x80;

//定时器正常工作

TSCR2=0x00;

//最后三位为预分频因子选择位

TFLG1=0xFF;

//清除该位

TFLG2=0x80;

//清除TOF

/********************************************************************************************/

//IO初始化子函数

/********************************************************************************************/

voidIO_init(void)

{//IO初始化函数

DDRA=0X00;

voidphoto()

unsignedchari,j;

for(i=0;

i<

=29;

i++)

for(j=0;

j<

=65;

j++)

if(shuzu[j]<

=60)

shuzu[j]=1;

else

shuzu[j]=0;

8位数据位,无奇偶校验,115200波特率,发送器和接收器都使能

48M总线时钟下适用

******************************************************************/

voidInit_SCI(void)

SCI0CR1=0x00;

//8位数据位,无奇偶校验

SCI0CR2=0x2c;

//允许接收和发送数据,允许接收中断功能

SCI0BD=0x2B;

//115200波特率

SCI发送一个字节数据

voidSCI_Send_Byte(unsignedchardata)

{

while(!

SCI0SR1_TDRE);

//等待发送数据寄存器中的值->

发送移位寄存器中

SCI0SR1_TC);

//等待发送移位寄存器中的数值发送完成

SCI0DRL=data;

SCI发送一个字符串

voidSCI_Send_Uchar_String(unsignedchar*putchar,uintnum)

uintcounter=0;

while((counter++)<

num)//判断字符串是否发送完毕

SCI_Send_Byte(*(putchar++));

voidSCI_Send_Image_String(unsignedchar*putchar,uintnum)

for(counter=0;

counter<

num;

counter++)

if(putchar[counter]==0x01)putchar[counter]=0x02;

SCI_Send_Byte(putchar[counter]);

voidmain(void){

/*putyourowncodehere*/

/*ucharx,data;

*/

crg_init();

ect_init();

IO_init();

Init_SCI();

PWM_Init();

EnableInterrupts;

for(;

;

){

_FEED_COP();

/*feedsthedog*/

}/*loopforever*/

/*pleasemakesurethatyouneverleavemain*/

/*********************************************

功能描述:

行中断服务程序,接PT0

参数说明:

返回说明:

修改记录:

注意事项:

*********************************************/

#pragmaCODE_SEGNON_BANKED

voidinterrupt8Port0_Interrupt()

inti=0,j=0;

unsignedchar*p;

TFLG1=0x01;

hang++;

//行计数器加1

if((hang<

30)||(hang>

240))

return;

//判断是否从新的一场开始

}

if(hang==hang_table[hang_count])//行数组采样变量

Delay

(1);

p=&

shuzu[hang_count][0];

shuzu[hang_count][0]=PORTA;

_asm();

shuzu[hang_count][1]=PORTA;

shuzu[hang_count][2]=PORTA;

shuzu[hang_count][3]=PORTA;

shuzu[hang_count][4]=PORTA;

shuzu[hang_count][5]=PORTA;

shuzu[hang_count][6]=PORTA;

shuzu[hang_count][7]=PORTA;

shuzu[hang_count][8]=PORTA;

shuzu[hang_count][9]=PORTA;

shuzu[hang_count][10]=PORTA;

shuzu[hang_count][11]=PORTA;

shuzu[hang_count][12]=PORTA;

shuzu[hang_count][13]=PORTA;

shuzu[hang_count][14]=PORTA;

shuzu[hang_count][15]=PORTA;

shuzu[hang_count][16]=PORTA;

shuzu[hang_count][17]=PORTA;

shuzu[hang_count][18]=PORTA;

shuzu[hang_count][19]=PORTA;

shuzu[hang_count][20]=PORTA;

shuzu[hang_count][21]=PORTA;

shuzu[hang_count][22]=PORTA;

shuzu[hang_count][23]=PORTA;

shuzu[hang_count][24]=PORTA;

shuzu[hang_count][25]=PORTA;

shuzu[hang_count][26]=PORTA;

shuzu[hang_count][27]=PORTA;

shuzu[hang_count][28]=PORTA;

shuzu[hang_count][29]=PORTA;

shuzu[hang_count][30]=PORTA;

shuzu[hang_count][31]=PORTA;

shuzu[hang_count][32]=PORTA;

shuzu[hang_count][33]=PORTA;

shuzu[hang_count][34]=PORTA;

shuzu[hang_count][35]=PORTA;

shuzu[hang_count][36]=PORTA;

shuzu[hang_count][37]=PORTA;

shuzu[hang_count][38]=PORTA;

shuzu[hang_count][39]=PORTA;

shuzu[hang_count][40]=PORTA;

shuzu[hang_count][41]=PORTA;

shuzu[hang_count][42]=PORTA;

shuzu[hang_count][43]=PORTA;

shuzu[hang_count][44]=PORTA;

shuzu[hang_count][45]=PORTA;

shuzu[hang_count][46]=PORTA;

shuzu[hang_count][47]=PORTA;

shuzu[hang_count][48]=PORTA;

shuzu[hang_count][49]=PORTA;

shuzu[hang_count][50]=PORTA;

shuzu[hang_count][51]=PORTA;

shuzu[hang_count][52]=PORTA;

shuzu[hang_count][53]=PORTA;

shuzu[hang_count][54]=PORTA;

shuzu[hang_count][55]=PORTA;

shuzu[hang_count][56]=PORTA;

shuzu[hang_count][57]=PORTA;

shuzu[hang_count][58]=PORTA;

shuzu[hang_count][59]=PORTA;

shuzu[hang_count][60]=PORTA;

shuzu[hang_count][61]=PORTA;

shuzu[hang_count][62]=PORTA;

shuzu[hang_count][63]=PORTA;

shuzu[hang_count][64]=PORTA;

shuzu[hang_count][65]=PORTA;

shuzu[hang_count][66]=PORTA;

shuzu[hang_count][67]=PORTA;

shuzu[hang_count][68]=PORTA;

shuzu[hang_count][69]=PORTA;

shuzu[hang_count][70]=PORTA;

shuzu[hang_count][71]=PORTA;

shuzu[hang_count][72]=PORTA;

shuzu[hang_count][73]=PORTA;

shuzu[hang_count][74]=PORTA;

shuzu[hang_count][75]=PORTA;

shuzu[hang_count][76]=PORTA;

shuzu[hang_count][77]=PORTA;

shuzu[hang_count][78]=PORTA;

shuzu[hang_count][79]=PORTA;

shuzu[hang_count][80]=PORTA;

shuzu[hang_count][81]=PORTA;

shuzu[hang_count][82]=PORTA;

shuzu[hang_count][83]=PORTA;

shuzu[hang_count][84]=PORTA;

shuzu[hang_count][85]=PORTA;

shuzu[hang_count][86]=PORTA;

shuzu[hang_count][87]=PORTA;

shuzu[hang_count][88]=PORTA;

shuzu[hang_count][89]=PORTA;

shuzu[hang_count][90]=PORTA;

shuzu[hang_count][91]=PORTA;

shuzu[hang_count][92]=PORTA;

shuzu[hang_count][93]=PORTA;

shuzu[hang_count][94]=PORTA;

shuzu[hang_count][95]=PORTA;

shuzu[hang_count][96]=PORTA;

shuzu[hang_count][97]=PORTA;

shuzu[hang_count][98]=PORTA;

shuzu[hang_count][99]=PORTA;

100;

j++,p++)

*p=shuzu[hang_count][j];

hang_count++;

if(hang_count==hangshu)

TIE=0x00;

//关行中断,场中断

SCI_Send_Byte(0x01);

SCI_Send_Image_String(&

shuzu[0][0],hangshu*lieshu);

TIE=0x02;

//开场中断

场中断服务程序,接PT1

#pragmaCODE_SEGNON_BANKED

interrupt9voidPT1_Interrupt(void)

TFLG1=0x03;

//清场中断,行中断

//开场中断,关行中断

hang=0;

lie=0;

hang_count=0;

WelcomeTo

Download!

!

欢迎您的下载,资料仅供参考!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1