Re: 發問前的準備 得到答案的回應 (新手必讀)
|
||||
---|---|---|---|---|
初級會員
|
其實去Google
最後查到的大多都會連回microchip的討論區 除了Google 也能使用 microchip 右上角的 "搜尋區塊" 搜尋
發表於: 2010/1/15 10:58
|
|||
|
Re: 研討會發的 "Embedded Designer's Forum" CD
|
||||
---|---|---|---|---|
初級會員
|
哈~
一開始我還疑為我拿到瑕疵品 想說自認倒楣算了 原來資料都在另一塊裡面!!
發表於: 2009/11/16 21:33
|
|||
|
Re: 數位輸出入阜 按鍵開關問題
|
||||
---|---|---|---|---|
初級會員
|
nicecookie 你好
很抱歉我沒有詳細說明我的問題 Sorry debug -> Run 中 無按下任何按鍵 LCD螢幕顯示 NO PUSH 按下 S1 LCD螢幕顯示 NO PUSH 按下 S2 LCD螢幕顯示 NO PUSH 按下任何按鍵 LCD螢幕顯示 NO PUSH 用中斷檢查發現 switch (Sw) <==若在此設為中斷點,則可以中斷 。 { case 1: //S1 Pressed DisplayS1(); <==若在此設為中斷點,則不能中斷 。 break ; case 2: //S2 Pressed DisplayS2(); break ; } 用watch 觀看Sw的值 無論按下S1、S2等任何按鍵 Sw的值 均為0x00 並無變化 不曉得 這樣的資料夠不夠齊全? Attach file: (0.00 KB)
發表於: 2009/10/20 20:43
|
|||
|
數位輸出入阜 按鍵開關問題
|
||||
---|---|---|---|---|
初級會員
|
使用PIC24FJ128GB106
按下按鍵開關SW1 ,LCD顯示 "PUSH S1" 按下按鍵開關SW2 ,LCD顯示 "PUSH S2" 編譯沒問題 但是當我按下任何按鍵開關 均無反應!! 請問有可能是哪邊出了問題?? 已參考過203_PRC 的 203Lab3 ========================================== #include <p24FXXXX.h> #include "lcd.h" #include <timer.h> #include <adc.h> #include <outcompare.h> #include <pps.h> #include <stdio.h> _CONFIG2(IESO_OFF & POSCMOD_HS & FNOSC_PRI& FCKSM_CSDCMD & PLLDIV_DIV2 ) _CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx2 & FWDTEN_OFF & WINDIS_OFF ) void PMP_Initial(void) ; void ADC_Initial(void) ; void Timer1_Initial(void) ; void OC_Initial(void) ; void DisplayS1(void) ; void DisplayS2(void) ; void IOInit(void) ; void ReadSwitch(void) ; #define INPUT 1 #define OUTPUT 0 #define Ctrl_U1RX TRISFbits.TRISF5 #define Ctrl_U1TX TRISFbits.TRISF3 #define S1 PORTBbit.RB3 #define S2 PORTBbit.RB5 unsigned char LCDString[] = "NO PUSH"; unsigned char LCDString1[] = "PUSH S1"; unsigned char LCDString2[] = "PUSH S2"; char Sw ; unsigned int Timer1Tick = 0,i = 0 ; unsigned int RPM = 0 ; unsigned UART_Timer = 0 ; void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) { IFS0bits.T1IF = 0 ; Timer1Tick = 1 ; } int main(void) { LCD_Delay200usX(50) ; ADC_Initial() ; PMP_Initial() ; Timer1_Initial(); OC_Initial() ; LCD_Initial() ; IOInit() ; LCD_SetCursor(2,0); putsLCD(LCDString); LCD_Delay200usX(500) ; while(1) { ReadSwitch(); switch (Sw) { case 1: //S1 Pressed DisplayS1(); break ; case 2: //S2 Pressed DisplayS2(); break ; } } } void DisplayS1(void) //顯示PUSH S1 { LCD_Delay200usX(50) ; LCD_SetCursor(0,0); putsLCD(LCDString1) ; LCD_Delay200usX(1000) ; } void DisplayS2(void) //顯示PUSH S2 { LCD_Delay200usX(50) ; LCD_SetCursor(0,1); putsLCD(LCDString2) ; LCD_Delay200usX(1000) ; } void IOInit(void) { AD1PCFG=0xffff ; TRISB = 0xffff ; TRISBbits.TRISB3 = 1; // S1 TRISBbits.TRISB5 = 1; // S2 } void ReadSwitch(void) { if (PORTBbits.RB3 == 1) Sw = 1; if (PORTBbits.RB5 == 1) Sw = 2; } void OC_Initial(void) { PR2 = 4096 ; T2CON = 0x8000 ; OC1CON1 = 0x000e ; OC1CON2 = 0x001f ; OC1R = 0 ; OC1RS = 1023 ; // Set RP2 as OC1 output !! // RP2 @ RD8 TRISDbits.TRISD8 = OUTPUT ; iPPSOutput(OUT_PIN_PPS_RP2,OUT_FN_PPS_OC1); } void Timer1_Initial(void) { // To make a 10 ms Timer @ Fosc = 8 Mhz -> Fcy = 4Mhz // Select 1:8 prescaler , Freq to Timer1 = 500 K -> 2 us // 10ms = 10000 us , 10000 us / 2 us = 5000 // So, PR1 = 4999 for a 10 ms Timer OpenTimer1( T1_ON & T1_IDLE_CON & T1_PS_1_8 & T1_SYNC_EXT_OFF & T1_GATE_OFF & T1_SOURCE_INT , 4999 ); ConfigIntTimer1(T1_INT_PRIOR_4 & T1_INT_ON) ; } void ADC_Initial(void) { AD1CON1 = 0b0000000000000110 ; // Mode : Clear SAMP start conversion // ASAM = 1 --> SAMP auto set AD1CON2 = 0b0000000000000000 ; AD1CON3 = 0b1000001100001111 ; // Internal RC as AD Clock AD1CHS = 0x00 ; // Use AN0 temporary AD1PCFG = 0b1111111111111011 ; // AN2 enabled AD1CON1bits.ADON = 1 ; } void PMP_Initial(void) { //******************************************************************************** // STEP 1: // Configure PMPCON: PMP on, address/data not multiplexed, PMPBE active high, // PMPWR I/O, PMPRD I/O, 8-bit data, PMPENB and PMPRD/~PMPWR active high. //********************************************************************************/ // PMCON = ; // Exer1 PMCON = 0b1000001100000111; //******************************************************************************** // STEP 2: // Configure PMPMODE: Interrupts, stall, buffers, inc/dec off, 8 bit mode, // combined read/write with byte enable signals, and max the 3 wait delays. //********************************************************************************/ // PMMODE = ; // Exer1 PMMODE = 0x23FF; //******************************************************************************** // STEP 3: // Configure PMAEN: Enable A0 function to control RS and disable all other // PMP address pins. //********************************************************************************/ // PMAEN = ; // Exer1 PMAEN = 0x0001; //******************************************************************************** // STEP 4: // Configure PMPADDR: A0 selects type of instruction, either command or data. // This is a command so A0 should be low. //********************************************************************************/ // PMADDR = ; // Exer1 PMADDR = 0x0000; } Attach file: Link only for registered users
發表於: 2009/10/20 13:03
|
|||
|
Re: 號外!舉凡參加2009嵌入式論壇"F/TCH "課程者,送小觸控電路板一片!
|
||||
---|---|---|---|---|
初級會員
|
還好我有選F
賺到一片小觸控電路板 我相信會有更多的優惠陸陸續續跑出來!!!
發表於: 2009/10/16 9:22
|
|||
|
Re: PICkit2燒錄問題,會出現下列訊息
|
||||
---|---|---|---|---|
初級會員
|
發表於: 2009/10/11 13:51
|
|||
|
Re: 請教GPS To Uart Receive By PIC24F
|
||||
---|---|---|---|---|
初級會員
|
本人以成功截取到GPS訊號
再次感謝所以觀看及回復我問題的人 將此檔案放在網路上供給需要的人做參考 GPS To Uart Receive By PIC24FJ218GB106 Attach file: Link only for registered users
發表於: 2009/10/7 23:34
|
|||
|
Re: 請教GPS To Uart Receive By PIC24F
|
||||
---|---|---|---|---|
初級會員
|
首先 我要感謝所以觀看及回覆我的問題的前輩
因為你們,我才得以進步,找出問題,解決方法!! 目前我已經可以做到接收GPS訊號並顯示資料!! 但卻跑出顯示的資料為亂碼!!(像是'['、'^'、日文、奇形怪狀的文字) 距離成功只差臨門一腳!!! 各位前輩方便的話,請幫我看看哪邊出錯導致顯示資料的時候為亂碼!! *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Module Name : GPS Receiver * //DATE : 2009.08.11 * *****************************************************************************/ #include <p24FXXXX.h> #include "lcd.h" #include <timer.h> #include <adc.h> #include <outcompare.h> #include <pps.h> #include <uart.h> #include <stdio.h> _CONFIG2(IESO_OFF & POSCMOD_HS & FNOSC_PRI& FCKSM_CSDCMD & PLLDIV_DIV2 ) _CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx2 & FWDTEN_OFF & WINDIS_OFF ) void PMP_Initial(void) ; void UART1_Initial(void) ; void ADC_Initial(void) ; void AD_Delay(void) ; void Timer1_Initial(void) ; void OC_Initial(void) ; void RX_ArrayDisplay(unsigned char *data) ; #define INPUT 1 #define OUTPUT 0 #define Ctrl_U1RX TRISFbits.TRISF5 #define Ctrl_U1TX TRISFbits.TRISF3 unsigned char LCDString[] = "GPS Receive"; unsigned int ADC_TempValue ; short int RX_int,RX_intArray[16] ; unsigned char RX_Test,RX_DATA,RX_ARRAY[16],LineCount = 0 ; unsigned char cnt=0; unsigned int Timer1Tick = 0,i = 0 ; unsigned int RPM = 0 ; unsigned UART_Timer = 0 ; unsigned char UART_RX_Flag = 0 ; void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void) // UART1接收資料中斷副程式 { IFS0bits.U1RXIF = 0 ; // 清除中斷旗標 RX_DATA = ReadUART1(); // Get RS-232 data 將UART讀取資料暫存器的內容讀出 RX_ARRAY[cnt] = RX_DATA ; if (cnt > 14) UART_RX_Flag = 1 ; // 設定接收狀態旗標為1 else { cnt++ ; UART_RX_Flag = 0 ; } } void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) { IFS0bits.T1IF = 0 ; Timer1Tick = 1 ; } int main(void) { LCD_Delay200usX(50) ; PMP_Initial() ; ADC_Initial() ; Timer1_Initial(); OC_Initial() ; UART1_Initial() ; LCD_Initial() ; LCD_SetCursor(2,0); putsLCD(LCDString); while(1) { if(UART_RX_Flag == 1) // 判斷資料傳送狀態旗標 { RX_ArrayDisplay(RX_ARRAY) ; //顯示RX_Array LCD_Delay200usX(500) ; UART_RX_Flag = 0 ; // 設定接收狀態旗標為0 cnt = 0 ; } } } void RX_ArrayDisplay(unsigned char *data) //顯示RX_Array { LCD_Delay200usX(50) ; LCD_SetCursor( 0,1); putsLCD(data) ; LCD_Delay200usX(1000) ; } void OC_Initial(void) { PR2 = 4096 ; T2CON = 0x8000 ; OC1CON1 = 0x000e ; OC1CON2 = 0x001f ; OC1R = 0 ; OC1RS = 1023 ; // Set RP2 as OC1 output !! // RP2 @ RD8 TRISDbits.TRISD8 = OUTPUT ; iPPSOutput(OUT_PIN_PPS_RP2,OUT_FN_PPS_OC1); } void UART1_Initial(void) { // Important system variable -> "__C30_UART" // 1 = UART1 // 2 = UART2 if using printf to output data to "stdout" unsigned int U1MODEvalue; unsigned int U1STAvalue; // **************************************************** // 設定 UART1 RX = RP10 -> Pin31 // 設定 UART1 TX = RP17 -> Pin32 // **************************************************** PPSUnLock ; CloseUART1(); ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR6 & UART_TX_INT_DIS & UART_TX_INT_PR2); iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP10); iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U1TX); U1MODEvalue = UART_EN & UART_IDLE_STOP & UART_EN_WAKE & UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_NO_PAR_8BIT & UART_1STOPBIT & UART_IrDA_DISABLE & UART_UEN_00 & UART_BRGH_SIXTEEN; U1STAvalue = UART_INT_TX_BUF_EMPTY & UART_SYNC_BREAK_DISABLED & UART_TX_ENABLE & UART_INT_RX_CHAR & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR; // ********************************************************** // 設定 UART 為 4800 bps // CPU Fosc = 8 Mhz -> Fcy = 4Mhz // ********************************************************** OpenUART1 ( U1MODEvalue , U1STAvalue , 51 ) ; //ConfigIntUART1(UART_RX_INT_EN & UART_TX_INT_EN) ; Ctrl_U1RX = INPUT ; Ctrl_U1TX = OUTPUT ; PPSLock ; } void Timer1_Initial(void) { // To make a 10 ms Timer @ Fosc = 8 Mhz -> Fcy = 4Mhz // Select 1:8 prescaler , Freq to Timer1 = 500 K -> 2 us // 10ms = 10000 us , 10000 us / 2 us = 5000 // So, PR1 = 4999 for a 10 ms Timer OpenTimer1( T1_ON & T1_IDLE_CON & T1_PS_1_8 & T1_SYNC_EXT_OFF & T1_GATE_OFF & T1_SOURCE_INT , 4999 ); ConfigIntTimer1(T1_INT_PRIOR_4 & T1_INT_ON) ; } void PMP_Initial(void) { //******************************************************************************** // STEP 1: // Configure PMPCON: PMP on, address/data not multiplexed, PMPBE active high, // PMPWR I/O, PMPRD I/O, 8-bit data, PMPENB and PMPRD/~PMPWR active high. //********************************************************************************/ // PMCON = ; // Exer1 PMCON = 0b1000001100000111; //******************************************************************************** // STEP 2: // Configure PMPMODE: Interrupts, stall, buffers, inc/dec off, 8 bit mode, // combined read/write with byte enable signals, and max the 3 wait delays. //********************************************************************************/ // PMMODE = ; // Exer1 PMMODE = 0x23FF; //******************************************************************************** // STEP 3: // Configure PMAEN: Enable A0 function to control RS and disable all other // PMP address pins. //********************************************************************************/ // PMAEN = ; // Exer1 PMAEN = 0x0001; //******************************************************************************** // STEP 4: // Configure PMPADDR: A0 selects type of instruction, either command or data. // This is a command so A0 should be low. //********************************************************************************/ // PMADDR = ; // Exer1 PMADDR = 0x0000; } void ADC_Initial(void) { AD1CON1 = 0b0000000000000110 ; // Mode : Clear SAMP start conversion // ASAM = 1 --> SAMP auto set AD1CON2 = 0b0000000000000000 ; AD1CON3 = 0b1000001100001111 ; // Internal RC as AD Clock AD1CHS = 0x00 ; // Use AN0 temporary AD1PCFG = 0b1111111111111011 ; // AN2 enabled AD1CON1bits.ADON = 1 ; } Attach file: Link only for registered users
發表於: 2009/10/7 15:20
|
|||
|
請教UART接收解碼問題
|
||||
---|---|---|---|---|
初級會員
|
我使用PIC24FJ128GB106
欲從PC上的超級終端機按字元,使PIC24FJ128GB106的LCD上顯示所接收到的字元 unsigned char RX_DATA ; RX_Data= ReadUART1(); 使用ReadUart1 Function This function returns the content of UART receive buffer (UxRXREG) register. 接著丟給RX_Data這個參數 RX_Data的value是16進位這個沒錯吧!? 我想請教的是,我在PC上的超級終端機每次都按下a 我從watch上看U1RXREG、RX_Data的Value 第一次 U1RXREG的Value為0x004F RX_Data的Value為0x00 第二次 U1RXREG的Value為0x000F RX_Data的Value為0x4F 第三次 U1RXREG的Value為0x004F RX_Data的Value為0x0F 第四次 U1RXREG的Value為0x000F RX_Data的Value為0x4F 會是我中斷點設錯嗎?? 還有為什麼我按下a,結果LCD顯示O 我程式哪邊寫錯??請各位前輩多多指教!!! 特別想請教我的U1MODEvalue這邊有沒有設錯??因為我之前就這邊設錯導致整個執行錯誤!! *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Module Name : GPS Receiver * //DATE : 2009.08.11 * *****************************************************************************/ #include <p24FXXXX.h> #include "lcd.h" #include <timer.h> #include <adc.h> #include <outcompare.h> #include <pps.h> #include <uart.h> #include <stdio.h> _CONFIG2(IESO_OFF & POSCMOD_HS & FNOSC_PRI& FCKSM_CSDCMD & PLLDIV_DIV2 ) _CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx2 & FWDTEN_OFF & WINDIS_OFF ) void PMP_Initial(void) ; void UART1_Initial(void) ; void ADC_Initial(void) ; void AD_Delay(void) ; void Timer1_Initial(void) ; void OC_Initial(void) ; void RX_BuffDisplay(void) ; #define INPUT 1 #define OUTPUT 0 #define Test_Array[16] unsigned char Test,*p ; #define Ctrl_U1RX TRISFbits.TRISF5 #define Ctrl_U1TX TRISFbits.TRISF3 unsigned char LCDString[] = "UART Receive"; unsigned int ADC_TempValue ; short int RX_int,RX_intArray[16] ; unsigned char RX_DATA,RX_ARRAY[16],LineCount = 0 ; unsigned char cnt=0; unsigned int Timer1Tick = 0,i = 0 ; unsigned int RPM = 0 ; unsigned UART_Timer = 0 ; unsigned char UART_RX_Flag = 0 ; void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void) // UART1接收資料中斷副程式 { IFS0bits.U1RXIF = 0 ; // 清除中斷旗標 RX_DATA = ReadUART1(); // Get RS-232 data 將UART讀取資料暫存器的內容讀出 UART_RX_Flag = 1 ; } void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) { IFS0bits.T1IF = 0 ; Timer1Tick = 1 ; } int main(void) { LCD_Delay200usX(50) ; PMP_Initial() ; ADC_Initial() ; Timer1_Initial(); OC_Initial() ; UART1_Initial() ; LCD_Initial() ; LCD_SetCursor(2,0); putsLCD(LCDString); while(1) { if(UART_RX_Flag == 1) // 判斷資料傳送狀態旗標 { RX_ARRAY[cnt] = RX_DATA ; UART_RX_Flag = 0; if(cnt = 15) { cnt = 0 ; LCD_Delay200usX(50) ; LCD_SetCursor( 0,1); putsLCD(RX_ARRAY) ; LCD_Delay200usX(1000) ; } else { cnt++; } } } } void OC_Initial(void) { PR2 = 4096 ; T2CON = 0x8000 ; OC1CON1 = 0x000e ; OC1CON2 = 0x001f ; OC1R = 0 ; OC1RS = 1023 ; // Set RP2 as OC1 output !! // RP2 @ RD8 TRISDbits.TRISD8 = OUTPUT ; iPPSOutput(OUT_PIN_PPS_RP2,OUT_FN_PPS_OC1); } void UART1_Initial(void) { // Important system variable -> "__C30_UART" // 1 = UART1 // 2 = UART2 if using printf to output data to "stdout" unsigned int U1MODEvalue; unsigned int U1STAvalue; // **************************************************** // 設定 UART1 RX = RP10 -> Pin31 // 設定 UART1 TX = RP17 -> Pin32 // **************************************************** PPSUnLock ; CloseUART1(); ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR6 & UART_TX_INT_DIS & UART_TX_INT_PR2); iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP10); iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U1TX); U1MODEvalue = UART_EN & UART_IDLE_STOP & UART_EN_WAKE & UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_NO_PAR_8BIT & UART_1STOPBIT & UART_IrDA_DISABLE & UART_UEN_00 & UART_BRGH_SIXTEEN; U1STAvalue = UART_INT_TX_BUF_EMPTY & UART_SYNC_BREAK_DISABLED & UART_TX_ENABLE & UART_INT_RX_CHAR & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR; // ********************************************************** // 設定 UART 為 4800 bps // CPU Fosc = 8 Mhz -> Fcy = 4Mhz // ********************************************************** OpenUART1 ( U1MODEvalue , U1STAvalue , 51 ) ; //ConfigIntUART1(UART_RX_INT_EN & UART_TX_INT_EN) ; Ctrl_U1RX = INPUT ; Ctrl_U1TX = OUTPUT ; PPSLock ; } Attach file: Link only for registered users (0.00 KB) (0.00 KB) (0.00 KB)
發表於: 2009/10/5 20:24
|
|||
|