智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 1357|回复: 0
打印 上一主题 下一主题

冰天雪地360度翻滚跪求帮助!!!

[复制链接]

3

主题

17

帖子

0

精华

高级会员

Rank: 4

积分
859
威望
546
贡献
177
兑换币
93
注册时间
2011-11-10
在线时间
68 小时
跳转到指定楼层
1#
发表于 2012-2-24 00:33:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
刚刚开始研究摄像头采样,用的是CCD的摄像头和片内AD转换,但是程序运行时发现采集到的图像的每一行的值都一样!!(行与行之间不同)而且保持不变。。源代码如下。。跪求帮助!!

void delay_ms(int ms);
void getimage();
int get,IRQ_count=0,PJ6_count=0;
char line=0;            //代表行数
byte pic[LINE_MAX][ROW_MAX]=0;
char LINE_NUMBER_SUM,LINE_INTERVAL;
/***********************PJ6中断初始化******************/
void PJ6_INIT(void)
{
    PPSJ_PPSJ6=0;    //初始化PJ6中断,上升沿中断?
    PIEJ=0xff;
    PERJ=0xff;
}
/*******************外部中断IRQ初始化******************/
void IRQ_INIT(void)
{
  IRQCR_IRQE=1;
  IRQCR_IRQEN=1;
  //下降沿触发,使能
}
void ad_init() {
   ATD0CTL2 = 0xc0;
   ATD0CTL3 = 0x08; //0x08
   ATD0CTL4 = 0x83;
   ATD0DIEN = 0x00;
   ATD0CTL5 = 0b10110000; //右对齐 无符号 连续
   
}
void main(void) {
  
  
  DisableInterrupts;

  ad_init();
  PJ6_INIT();
  IRQ_INIT();
  
   EnableInterrupts;
  for(;;) {
    _FEED_COP();
  }
}

void delay_ms(int ms)
{
   int ii,jj;
   if (ms<1) ms=1;
   for(ii=0;ii<ms;ii++)
     for(jj=0;jj<2670;jj++);    //busclk:16MHz--1ms
}
/********************IRQ中断服务程序************************************/
#pragma CODE_SEG NON_BANKED
void interrupt 6 IRQ()
{
    line=0;
    LINE_INTERVAL=4;
    IRQ_count++;
    if(IRQ_count>32760) IRQ_count = 0;
    OPEN_PJ6;
    CLOSE_IRQ;
   
   
   
}
void getimage() {
   uchar j,i;
  _asm();_asm();           
  pic[line][0]=get_ad();;_asm();
  pic[line][1]=get_ad();;_asm();
  pic[line][2]=get_ad();;_asm();
  pic[line][3]=get_ad();;_asm();
  pic[line][4]=get_ad();;_asm();
  pic[line][5]=get_ad();;_asm();
  pic[line][6]=get_ad();;_asm();
  pic[line][7]=get_ad();;_asm();
  pic[line][8]=get_ad();;_asm();
  pic[line][9]=get_ad();;_asm();
  pic[line][10]=get_ad();;_asm();
  pic[line][11]=get_ad();;_asm();
  pic[line][12]=get_ad();;_asm();
  pic[line][13]=get_ad();;_asm();
  pic[line][14]=get_ad();;_asm();
  pic[line][15]=get_ad();;_asm();
  pic[line][16]=get_ad();;_asm();
  pic[line][17]=get_ad();;_asm();
  pic[line][18]=get_ad();;_asm();
  pic[line][19]=get_ad();;_asm();
  pic[line][20]=get_ad();;_asm();
  pic[line][21]=get_ad();;_asm();
  pic[line][22]=get_ad();;_asm();
  pic[line][23]=get_ad();;_asm();
  pic[line][24]=get_ad();;_asm();
  pic[line][25]=get_ad();;_asm();
  pic[line][26]=get_ad();;_asm();
  pic[line][27]=get_ad();;_asm();
  pic[line][28]=get_ad();;_asm();
  pic[line][29]=get_ad();;_asm();
  if(++line>=LINE_MAX)
    {//一场已经采完,关闭PJ中断
      CLOSE_PJ6;
      
      OPEN_IRQ;
    }
}

/*********************PJ6中断服务***************************************/
#pragma CODE_SEG NON_BANKED
void interrupt 24 PJ6()
{
  
  if(++LINE_NUMBER_SUM%LINE_INTERVAL==0 && LINE_NUMBER_SUM>=10)
  {
     PJ6_count++;
     PIFJ=0xFF;   //清除标致位
     if(PJ6_count>32760) PJ6_count = 0;
     getimage();
  }
  
   
   
   
}
char get_ad() {
  while(!ATD0STAT2_CCF0)
    return AD;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关于我们|联系我们|小黑屋|智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-10-5 06:35 , Processed in 0.066770 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表