101 FW HID
|
||||
---|---|---|---|---|
中級會員
|
您好, 小弟現正研究USB101 FW, 並且期望在程式中加入PORTB高中斷的功能, 以下是我的程式碼, 請參考:
void main(void) { PORTBbits.RB5=1; TRISBbits.TRISB5=1; RCONbits.IPEN=1; // Enable Interrupt Priority bit INTCONbits.GIEH=1; // Enable High Priority Interrupt k=PORTBbits.RB5; // Read value of PORTB while initialing INTCONbits.RBIF=0; // Clear PORTB change interrupt flag INTCONbits.RBIE=1; // Enable High Priority Interrupt InitializeSystem(); OpenLCD() ; OpenPORTB(0xFF); // Turn on PORTB with Interrupt //putrsLCD("PIC18F4550 Test") ; j=0; while (j<10 && !i) { j++; itoa(j,LCD_String); LCD_Set_Cursor(0,5); putsLCD(LCD_String); itoa(i,LCD_String); LCD_Set_Cursor(0,10); putsLCD(LCD_String); for(l=0;l<3;l++) Delay10KTCYx(200); // Delay 1 second } // End while (j<30 && !SYS_POWER && !power_on) if (j==10) { LCD_Set_Cursor(0,0); putrsLCD("Sleeping"); Sleep(); } // End if (j==30) while(1) { USBTasks(); // USB Tasks ProcessIO(); // See user\user.c & .h } //end while }//end main /* High priority interrupt When getting button signle, PIC will send a pulse*/ #pragma code isrhighcode = 0x0008 void isr_high_direct(void) { _asm //begin in-line assembly goto isr_high //go to isr_high function _endasm //end in-line assembly } // End isr_high_direct() #pragma code #pragma interrupt isr_high void isr_high(void) { i=1; k=PORTBbits.RB5; INTCONbits.RBIF=0; } // End isr_high() #pragma code 現在問題是 : 倘若等到j數到10, 進入sleep mode之後再按RB5使其醒來, 在XP裡面可以認到USB裝置; 但是若是在j數到10之前按下RB5, 就會發生USB裝置無法辨識的情形, 請問這是什麼原因呢? 謝謝
發表於: 2008/4/8 17:55
|
|||
|