初始化錯誤碼是0x81,我用的是mega128單片機,并口模式,我在這個論壇上看到了很多這個問題的帖子,但沒能解決我的問題。管腳確定是接通的。用的是模塊。 26管腳rst#是高電平,rst管腳低電平(這沒有問題吧,我在其他帖子里看是這樣的),晶振電壓一個是2.45V,一個是2.39V,由于沒有示波器,無法看是否起振 很奇怪的是所有的數(shù)據(jù)口通通輸出高電平,不管輸入什么,都返回高電平,在這里也看到了這個問題:http://m.findthetime.net/bbs/View.asp?S=101&I=24429,不知道是怎么解決的,著急??!這是部分程序代碼: void CH375_PORT_INIT(void) { Set_Bit(DDRF,CH375_RSTI); Set_Bit(PORTF, CH375_RSTI); Only_Delay_Ms(3); Clr_Bit(PORTF, CH375_RSTI); Only_Delay_Ms(500);
DDRA = 0x00; PORTA = 0xff;
Set_Bit(DDRG,CH375_WRITE_ENABLE); Set_Bit(DDRG,CH375_READ_ENABLE); Set_Bit(DDRC,CH375_CHIP_ENABLE); Set_Bit(DDRC,CH375_A0); Clr_Bit(DDRE,CH375_INT); Clr_Bit(DDRE,CH375_ACT);
Set_Bit(PORTG,CH375_WRITE_ENABLE); Set_Bit(PORTG,CH375_READ_ENABLE); Set_Bit(PORTC,CH375_CHIP_ENABLE); Set_Bit(PORTC,CH375_A0); Set_Bit(PORTE,CH375_INT); Set_Bit(PORTE,CH375_ACT); }
/*375的命令執(zhí)行,往ch375寫命令*/ void xWriteCH375Cmd( UINT8 mCmd ) { DDRA = 0xFF; PORTA = mCmd; Clr_Bit(PORTC,CH375_A0); Clr_Bit(PORTC,CH375_CHIP_ENABLE); Clr_Bit(PORTG,CH375_WRITE_ENABLE); _delay_us(2); //Only_Delay_Ms(1); //DDRA = 0xFF; //This operation has no sense,only as delay time //DDRA = 0xFF; Set_Bit(PORTG,CH375_WRITE_ENABLE); Set_Bit(PORTG,CH375_READ_ENABLE); Set_Bit(PORTC,CH375_CHIP_ENABLE); DDRA = 0x00; //Clr_Bit(PORTC,CH375_A0); }
/*往CH375中寫數(shù)據(jù)*/ void xWriteCH375Data( UINT8 mData ) { DDRA = 0xFF; PORTA = mData;
Set_Bit(PORTC,CH375_A0); Clr_Bit(PORTC,CH375_CHIP_ENABLE); Clr_Bit(PORTG,CH375_WRITE_ENABLE); _delay_us(2); //Only_Delay_Ms(1); //DDRA = 0xFF; //This operation has no sense,only as delay time //DDRA = 0xFF; Set_Bit(PORTG,CH375_WRITE_ENABLE); Set_Bit(PORTG,CH375_READ_ENABLE); Set_Bit(PORTC,CH375_A0); Set_Bit(PORTC,CH375_CHIP_ENABLE); DDRA = 0x00; //Only_Delay_Ms(1); }
/*從CH375中讀取數(shù)據(jù)*/ UINT8 xReadCH375Data( void ) { uint8_t data = 0;
DDRA = 0x00; PORTA = 0xff; Set_Bit(PORTC,CH375_A0); Clr_Bit(PORTC,CH375_CHIP_ENABLE); Clr_Bit(PORTG,CH375_READ_ENABLE); _delay_us(2); //Only_Delay_Ms(1); //DDRA = 0x00; //This operation has no sense,only as delay time //DDRA = 0x00; data = PINA; Set_Bit(PORTG,CH375_WRITE_ENABLE); Set_Bit(PORTG,CH375_READ_ENABLE); Set_Bit(PORTC,CH375_CHIP_ENABLE); Set_Bit(PORTC,CH375_A0); return data; } 謝謝各位大蝦!