金牌会员
- 积分
- 1281
- 威望
- 750
- 贡献
- 395
- 兑换币
- 24
- 注册时间
- 2012-4-2
- 在线时间
- 68 小时
|
断点断了 发表于 2012-6-22 22:19
先晒下你的采集程序..估计程序上面有点纰漏...
#include "include.h"
#include "photo.h"
#define ROW 47
#define COLUMN 120
unsigned char Buffer[ROW][COLUMN];
unsigned char Image_Data[ROW][COLUMN];
unsigned char Point_C, VSYN_C=0, m = 0,n=0;
unsigned int Line_C=0;
unsigned char Interval;
unsigned char THRESHOLD=0x45;
void Image_Binaryzation(unsigned int row) //二值化程序
{
unsigned char *p_Image;
unsigned char *q_Image;
q_Image=&Buffer[row][0];
for(p_Image=&Image_Data[row][0];p_Image<=&Image_Data[row][COLUMN-1];p_Image++)
{
*(q_Image++)=*p_Image;
/*if((*p_Image<THRESHOLD))//&&(*(p_Image+1)<THRESHOLD))
*(q_Image++)=0;
else
*(q_Image++)=1; */
}
}
void delay_hang(unsigned char tt)
{
while(tt-->0)
{
asm("nop"); //延时一个机器周期
}
}
void show_photo()
{
unsigned char i,j;
/*for(i = 0;i<ROW;i++)
{
for(j = 0;j <COLUMN ;j++)
{
//if(Image_Data[j]>THRESHOLD && Image_Data[j+1]>THRESHOLD && Image_Data[j-1]>THRESHOLD)
if(Image_Data[j]>THRESHOLD) Image_Data[j]=1;//printf("%d",1);
else Image_Data[j]=0;//printf("%d",0);
//printf("%d",Image_Data[j]);
}
// uart_sendN(UART1,"\n",1);
}*/
uart_putchar(UART1,0x00);
uart_putchar(UART1,0xff);
uart_putchar(UART1,0x01);
uart_putchar(UART1,0x00);
for(i = 0;i<ROW;i++)
{
for(j = 0;j <COLUMN ;j++)
{
printf("%d",Image_Data[j]);
}
}
//printf("欢迎使用野火Kinetis开发板\n");
}
void main()
{
DisableInterrupts;
u8 i;
for(i=0;i<=7;i++)
{
gpio_init(PORTD,i,GPI,0);
}
LED_init();
exti_init(PORTC,10,falling_down); //C10场中断
exti_init(PORTA,24,rising_down); //A24行中断
EnableInterrupts;
PORTA_ISFR |= (1<<24); //清行中断
PORTC_ISFR |= (1<<10); //清场中断
enable_irq(87); //开行中断
enable_irq(89); //开场中断
for(;;)
{
if(VSYN_C)
{
led(LED2,LED_ON);
DisableInterrupts;
show_photo(); //显示采集数据
VSYN_C=0;
EnableInterrupts;
}
}
}
void PORTA_IRQHandler() //A24行中断
{
u8 i,j;
u8 n=24;
led(LED1,LED_ON);//引脚号
if(PORTA_ISFR & (1<<n)) //A24触发中断
{
PORTA_ISFR |= (1<<n);
m=0;
/*if ( VSYN_C==0|| m<12 || m>288 )
{
return;//判断是否从新的一场开始
}
if(m<=144) Interval=12;
else if(m>144&&m<=200) Interval=8;
else if(m>200&&m<=252) Interval=6;
else Interval=4; */
delay_hang(50);//消隐
Interval=6;
if(m%Interval==0)
{
for(i=0;i<ROW;i++)
{
for(j=0;j<COLUMN;j++)
{
Image_Data[Line_C][j]=PTD_BYTE0_IN;
m=m;
}
Line_C++;
}
m++;
Image_Binaryzation(Line_C);
}
}
}
void PORTC_IRQHandler() //C10场中断
{
disable_irq(87);
u8 n=10; //引脚号
led(LED0,LED_ON);
if(PORTC_ISFR & (1<<n)) //C10触发中断
{
disable_irq(87);
PORTC_ISFR |= (1<<n);
//Point_C = 0;
Line_C = 0; //行计数器
m=0;
VSYN_C = 1;
PORTC_ISFR |= (1<<n); //写1清中断标志位
}
enable_irq(87); //开启行中断
}
这就是我的程序,帮我看看哪有瑕疵,改很多遍都是不行,现在都不知道怎么改了
|
|