金牌会员
- 积分
- 1382
- 威望
- 406
- 贡献
- 768
- 兑换币
- 10
- 注册时间
- 2009-9-4
- 在线时间
- 104 小时
|
大体思路是每采完一场就关掉中断,通过串口把二值化后的图像发到PC上,出现的问题是发过来的东西全是0(阈值没有问题) - -!
-
- #define BUFF_ROW_MAX 15
- #define BUFF_COLUMN_MAX 50
-
- volatile unsigned char buff[BUFF_ROW_MAX][BUFF_COLUMN_MAX]; //存采集的数据
- volatile unsigned int SampleRow = 0; //避过场消隐用
- volatile unsigned char threshold = 0x2F; //阈值
- volatile unsigned char row = 0, column = 0;
- volatile unsigned char SCIrow = 0, SCIcolumn = 0;
- volatile Bool vStartFalg = 1; //标志新的一场开始
-
- void interrupt 8 Port0_interrupt(void) // HS interrupt
- {
- unsigned int i;
- TFLG1_C0F = 1; // Clear HS interrupt flag
- TIE_C0I = 0; // Disable HS interrupt
-
- if( vStartFalg ) // Avoid VS blanking
- {
- if ( SampleRow++ <= 5 )
- {
- return;
- }
- }
- for( i = 0; i < 55; i++) // Avoid HS blanking
- {
- asm(nop);
- }
- for( column = 0; column < BUFF_COLUMN_MAX; column++ )
- {
- while(!ATD0STAT0_SCF);
- buff[row][column] = ATD0DR0L;
- }
- //TIE_C0I = 0; // Disable HS interrupt,just sample one row.
- vStartFalg = 0;
-
- if( row++ <= BUFF_ROW_MAX )
- {
- TIE_C0I = 1;
- }
- }
- void interrupt 9 Port1_interrupt(void)
- {
- TIE_C0I = 0; // Disable HS interrupt
- TFLG1_C1F = 1; // Clear VS interrupt flag
- /**************************************
- * Send Image *
- **************************************/
- TIE_C1I = 0;
- for( SCIrow = 0; SCIrow < BUFF_ROW_MAX; SCIrow++ )
- {
- for( SCIcolumn = 0; SCIcolumn < BUFF_COLUMN_MAX; SCIcolumn++ )
- {
- if(buff[SCIrow][SCIcolumn] > threshold)
- SCI_Transmit('1');
- else
- SCI_Transmit('0');
- delayms(150);
- }
- SCI_Transmit('\n');
- }
- SCI_Transmit('\n');
- /**************************************
- * End of Sending *
- **************************************/
- //PORTB = ~PORTB;
-
- delayms(2);
- SampleRow = 0;
- vStartFalg = 1;
- row = 0; // Reinitialize
- TIE_C1I = 1; // Enable VS interrupt
- TIE_C0I = 1; // Enable HS interrupt
- }
-
复制代码
麻烦帮忙看看或者分享一下能实现的代码,谢谢啦~~ |
|