• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users




« 1 2 3 (4)


Re: 請教GPS To Uart Receive By PIC24F
#9
版主
版主


查看用戶資訊
謝謝颱風兄的解說,rar 現可以修復讀取了。

發表於: 2009/8/25 15:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#8
資深會員
資深會員


查看用戶資訊
以HEX模式打開.rar,發現多了0x0d+0x0a,「以文字模式送出二進元檔案」,很明顯這是網站設計者的問題。

使用 command 'r' 來修復。WinRAR 的情況,簡單按一下醫藥箱就可以了。

謝謝收聽,完畢。

發表於: 2009/8/22 20:50
The Answer to Life, the Universe, and Everything.
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#7
初級會員
初級會員


查看用戶資訊
我解壓縮成功耶...使用7z軟體
會是軟體的關係嗎?

發表於: 2009/8/22 20:09
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#6
版主
版主


查看用戶資訊
rar 的檔案格式在此討論區我從來沒有解壓縮成功過,我想是此網站的因素。所以請各位網友使用 ZIP 的格式來上傳檔案。
Thanks,

發表於: 2009/8/21 9:42
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#5
資深會員
資深會員


查看用戶資訊
教學相長,也許哪天我有問題,
請您不吝指教,謝謝!

Attach file:


Link only for registered users

發表於: 2009/8/20 16:29
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#4
初級會員
初級會員


查看用戶資訊
參照:

lancer0498 寫道:
我當初是用p18F4520來寫接收gps資料,
寫了一個簡單的範例確定能收之後就丟給學弟去改了,
如果你需要的話我再po給你參考,
但是我沒有將收進來的資料處理過,你可以自行處理一下!

那不好意思請妳PO一下你完成的程式
我也有參考妳發表過的文章!!感謝妳~~

發表於: 2009/8/20 14:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#3
資深會員
資深會員


查看用戶資訊
我當初是用p18F4520來寫接收gps資料,
寫了一個簡單的範例確定能收之後就丟給學弟去改了,
如果你需要的話我再po給你參考,
但是我沒有將收進來的資料處理過,你可以自行處理一下!

發表於: 2009/8/20 11:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教GPS To Uart Receive By PIC24F
#2
版主
版主


查看用戶資訊
//***********************************************
//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_PRIFCKSM_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         U1RXInterrupt(void) ;

#define        INPUT         1
#define        OUTPUT        0

#define        Ctrl_U1RX     TRISFbits.TRISF5 
#define        Ctrl_U1TX     TRISFbits.TRISF3 

#define     BuffLen     16     // 定義緩衝區長度 
unsigned char     RxBuff[BuffLen];

unsigned int    ADC_TempValue ;    

int        Timer1Tick ;
unsigned int    RPM ;
unsigned    UART_Timer ;
unsigned     UART_RX_Flag 0;


int main(void)
{

    
LCD_Delay200usX(50) ;

        
PMP_Initial() ;
        
ADC_Initial() ;
        
Timer1_Initial();
        
OC_Initial() ;
        
UART1_Initial() ;
        
LCD_Initial() ;

    while(
UART_RX_Flag)
 
    {    
//        U1RXInterrupt() ;       // 刪掉

        
LCD_SetCursor(0,1) ; 
        
putLCD(RxBuff[0]) ;    // 先測一下 RxBuff[0], putrsLCD( ) 是送出 ROM 的字串,應該用 putLCD( ) 或 pursLCD( ) 才對
        
UART_RX_Flag=0;

//        LCD_SetCursor(0,2) ; 
//        putLCD(RxBuff[0] ;     
//        LCD_SetCursor(0,3) ; 
    
}

}
[
color=ff0000UART 的中斷函數寫錯了,所以接收不會有中斷發生的 [/color
void __attribute__((interruptno_auto_psv)) _U1RXInterrupt(void)        // UART1接收資料中斷副程式
{

//    unsigned char cnt; 

    
RxBuff[0]=ReadUART1();     // Get RS-232 data    將UART讀取資料暫存器的內容讀出
    
UART_RX_Flag 1;

//       if(cnt>BuffLen-1)             
//    {
//        cnt=0;
//    }
        
    
IFS0bits.U1RXIF ;

}

void void __attribute__((interruptno_auto_psv)) _T1Interrupt(void)
{
   
IFS0bits.T1IF ;                                   
   
Timer1Tick ;
}

void    OC_Initial(void)
{    
        
PR2 4096 ;
        
T2CON 0x8000 ;
        
OC1CON1 0x000e ;
        
OC1CON2 0x001f ;
        
OC1R ;
        
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)
{
        
        
int    config1 config2 ;
        
iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP10);
        
iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U1TX);
             
        
config1 =     UART_EN UART_IDLE_CON 
                       
UART_DIS_WAKE UART_DIS_LOOPBACK 
                    
UART_DIS_ABAUD UART_NO_PAR_8BIT UART_1STOPBIT 
                    
UART_IrDA_DISABLE UART_MODE_SIMPLEX UART_UEN_00 
                    
UART_UXRX_IDLE_ONE UART_BRGH_FOUR ;

        
config2 =     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_IrDA_POL_INV_ZERO ;

        
//    **********************************************************
        //    設定 UART 為 9600 bps 
        //  CPU Fosc = 8 Mhz
        //    **********************************************************
        //OpenUART1 ( config1 , config2 , 25 ) ;
        //    **********************************************************
        //    設定 UART 為 4800 bps 
        //  CPU Fosc = 8 Mhz -> Fcy = 4Mhz
        //    **********************************************************
        
OpenUART1 config1 config2 51 ) ;        
        
ConfigIntUART1(UART_RX_INT_DIS UART_TX_INT_DIS) ;

         
Ctrl_U1RX INPUT ;
        
Ctrl_U1TX OUTPUT ;

}


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
        
        
OpenTimer1T1_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 ;
}

void    AD_Delay(void)
{
        
int    LoopVar ;
        
int    LoopVar2 LoopVar3 ;
        
        for ( 
LoopVar LoopVar 100 LoopVar++ )
        
LoopVar2 LoopVar3 ;
        
}

發表於: 2009/8/20 10:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請教GPS To Uart Receive By PIC24F
#1
初級會員
初級會員


查看用戶資訊
本人使用PIC24FJ128GB106
欲透過UART取出GPS資料,結果LCD上沒有顯示任何東西
程式是由網路學園裡的UART_Exercis更改,並參考討論區有關UART的文章
程式如下,請個為前輩指點
//***********************************************
//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_PRIFCKSM_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         U1RXInterrupt(void) ;

#define        INPUT         1
#define        OUTPUT        0

#define        Ctrl_U1RX     TRISFbits.TRISF5 
#define        Ctrl_U1TX     TRISFbits.TRISF3 

#define     BuffLen     16     // 定義緩衝區長度 
unsigned char     RxBuff[BuffLen];

unsigned int    ADC_TempValue ;    

int                Timer1Tick ;
unsigned int    RPM ;
unsigned        UART_Timer ;

int main(void)
{

        
LCD_Delay200usX(50) ;

        
PMP_Initial() ;
        
ADC_Initial() ;
        
Timer1_Initial();
        
OC_Initial() ;
        
UART1_Initial() ;
        
LCD_Initial() ;

    while(
1
    {    
        
U1RXInterrupt() ;
        
LCD_SetCursor(0,1) ; 
        
putrsLCD(RxBuff[0]) ;
        
LCD_SetCursor(0,2) ; 
        
putrsLCD(RxBuff[1]) ;
        
LCD_SetCursor(0,3) ; 
    }

}

void U1RXInterrupt(void)        // UART1接收資料中斷副程式
{

    
unsigned char cnt

    
RxBuff[cnt++]=ReadUART1();     // Get RS-232 data    將UART讀取資料暫存器的內容讀出

    
if(cnt>BuffLen-1)             
    {
        
cnt=0;
    }
        
    
IFS0bits.U1RXIF ;

}

void _ISR _T1Interrupt(void)
{
   
IFS0bits.T1IF ;                                   
   
Timer1Tick ;
}

void    OC_Initial(void)
{    
        
PR2 4096 ;
        
T2CON 0x8000 ;
        
OC1CON1 0x000e ;
        
OC1CON2 0x001f ;
        
OC1R ;
        
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)
{
        
        
int    config1 config2 ;
        
iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP10);
        
iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U1TX);
             
        
config1 =     UART_EN UART_IDLE_CON 
                       
UART_DIS_WAKE UART_DIS_LOOPBACK 
                    
UART_DIS_ABAUD UART_NO_PAR_8BIT UART_1STOPBIT 
                    
UART_IrDA_DISABLE UART_MODE_SIMPLEX UART_UEN_00 
                    
UART_UXRX_IDLE_ONE UART_BRGH_FOUR ;

        
config2 =     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_IrDA_POL_INV_ZERO ;

        
//    **********************************************************
        //    設定 UART 為 9600 bps 
        //  CPU Fosc = 8 Mhz
        //    **********************************************************
        //OpenUART1 ( config1 , config2 , 25 ) ;
        //    **********************************************************
        //    設定 UART 為 4800 bps 
        //  CPU Fosc = 8 Mhz -> Fcy = 4Mhz
        //    **********************************************************
        
OpenUART1 config1 config2 51 ) ;        
        
ConfigIntUART1(UART_RX_INT_DIS UART_TX_INT_DIS) ;

         
Ctrl_U1RX INPUT ;
        
Ctrl_U1TX OUTPUT ;

}


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
        
        
OpenTimer1T1_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 ;
}

void    AD_Delay(void)
{
        
int    LoopVar ;
        
int    LoopVar2 LoopVar3 ;
        
        for ( 
LoopVar LoopVar 100 LoopVar++ )
        
LoopVar2 LoopVar3 ;
        
}

發表於: 2009/8/20 9:10

Edited by Ryang on 2009年08月20日 10:16:06
Edited by Ryang on 2009年08月20日 10:18:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------