常驻嘉宾
- 积分
- 5379
- 威望
- 2669
- 贡献
- 1706
- 兑换币
- 1811
- 注册时间
- 2012-10-29
- 在线时间
- 502 小时
|
- #include <hidef.h> /* common defines and macros */
- #include "derivative.h"
- #pragma CODE_SEG __NEAR_SEG NON_BANKED
- //#define PORTE_PE0
- #define Field_Delete 3
- #define LINE 60
- #define COL 50//76
- #define BUSCLK 64000000 //总线频率
- #define OSCCLK 16000000 //晶振频率
- #define BAUD 9600 //波特率
- #define THRESHOLD 20 //阈值
- //定义变量
- //
- unsigned int Line_Select[LINE]=
- {
- 21,24,27,30,33,36,39,42,45,48,
- 51,54,57,60,63,66,69,72,75,78,
- 81,84,87,90,93,96,99,102,105,108,
- 111,114,117,120,123,126,129,132,135,138,
- 141,144,147,150,153,156,159,162,165,168,
- 171,174,177,180,183,186,189,192,195,198
- };
- unsigned char IMG[LINE][COL]=
- {0
- };
- unsigned int Line_cnt = 0; //行计数
- unsigned int Field_cnt = 0; //场计数
- unsigned int Used_Line = 0; //所用行的指针
- unsigned int a,k,temp = 0;
- unsigned char POST_PE2 = 0;
- //unsigned char IMG[LINE][COL];
- //unsigned char (*Pix_point)[COL] = IMG;
- unsigned char SCI_ENABLE_FLAG = 0;
- interrupt 6 void IRQ_ISR(void)
- {
- if(PORTE_PE2!=POST_PE2) //判断是否是新的一场,
- //即判断场中断的端口值是否发生改变
- {
- Line_cnt = 0; //新的一场,行计数清零
- Field_cnt ++; //场计数加一
- Used_Line = 0;
- // if(Used_Line > LINE)
- // {
- // SCI_ENABLE_FLAG = 1;
- // }
- }
- else if (Field_cnt >= Field_Delete) //判断场数,用以舍弃前几场, //去场消隐?好像不是
- //如果大于舍弃掉的场数,则开始采集
- {
- if (Line_cnt == Line_Select[Used_Line]) //如果行计数等于所需采集行,则进行采集
- //因为所需采集行数组可自行设置,可避开消隐区
- {
- SCI_ENABLE_FLAG = 0;
- k = 53;
- while(k--); //去行消隐
- //开始采集
- for(a=0; a<COL; a++)
- {
-
- temp = 0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
- temp += PORTK_PK0;
-
- IMG[Used_Line][a] = 1;
-
- }
-
- Used_Line++;
- }
- Line_cnt++;
- }
- }
- void SetBusCLK_64M(void)
- {
- CLKSEL=0x00; //disengage PLL to system
- PLLCTL_PLLON=1; //turn on PLL
- SYNR =0xC0 | 0x07;
- REFDV=0x80 | 0x01;
- POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=128MHz;
- _asm(nop); //BUS CLOCK=64M
- _asm(nop);
- while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
- CLKSEL_PLLSEL =1; //engage PLL to system;
- }
- void SCI_INIT(void)
- {
- SCI0BD = BUSCLK/16/BAUD;// 0x01A0; //设置SCI0波特率为9600
- SCI0CR1 = 0x00; //设置SCI0为正常工作模式,八位数据位,无奇偶校验
- SCI0CR2 = 0x08;
- }
-
- void uart_putchar(unsigned char ch)
- {
- while(!(SCI0SR1&0x80)) ; //keep waiting when not empty
- SCI0DRL=ch;
- }
-
-
-
- void Send_IMG(void)
- {
- unsigned int i,j;
- for(i=0; i<LINE; i++)
- {
- for(j=0; j<COL; j++)
- {
- uart_putchar(IMG[i][j]+0x30); //
- }
- uart_putchar('\n');
- uart_putchar('\r');
- }
- uart_putchar('\n');
- uart_putchar('\r');
- uart_putchar('\n');
- uart_putchar('\r');
- uart_putchar('\n');
- uart_putchar('\r');
- }
- void main(void) {
- //int i,j;
- /* put your own code here */
- DisableInterrupts;
-
- SetBusCLK_64M();
- SCI_INIT();
- // DDRB = 0xFF;
- // PORTB = 0x00;
复制代码 所有的代码都写在一个主函数里了,BDM在线调试时,一开始还能正常发回几个‘1’,接着就就发回‘0’了,目测是复位了,然后过一会儿程序就停止了,怎么回事啊?感觉中断没写错啊?求大神赐教
|
|