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

論壇索引


Board index » All Posts (黃金葛)




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


真的很不好意思...又來不恥下問
我閱讀過Microchip PIC24F Peripheral Library.chm之後再去更改,還是不能!!
用中斷來檢查,結果是不能中斷!!
在執行debugger run中
觀察 View -> watch -> RX_Buff 一直為Reserved Memory
方便幫我看看哪裡設定出錯嗎??感謝!!


void UART1_Initial(void)
{
// Important system variable -> "__C30_UART"
// 1 = UART1
// 2 = UART2 if using printf to output data to "stdout"

int config1 , config2 ;

// ****************************************************
// 設定 UART1 RX = RP10 -> Pin31
// 設定 UART1 TX = RP17 -> Pin32
// ****************************************************
PPSUnLock ;

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_EN_LOOPBACK \
& UART_EN_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 為 4800 bps
// CPU Fosc = 8 Mhz -> Fcy = 4Mhz
// **********************************************************
OpenUART1 ( config1 , config2 , 51 ) ;
ConfigIntUART1(UART_RX_INT_EN & UART_TX_INT_EN) ;

Ctrl_U1RX = INPUT ;
Ctrl_U1TX = OUTPUT ;

PPSLock ;
}

Attach file:


Link only for registered users

發表於: 2009/9/16 22:47
頂部


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


參照:

Ryang 寫道:
參照:
while(1)
{
LCD_SetCursor( 0,0);

putsLCD(LCDString); <== 執行到這裡有顯示嗎?
// 如果沒有代表出史話設定就有問題了。

if(UART_RX_Flag==1) // 判斷資料傳送狀態旗標
{
LCD_SetCursor( 0,0);
putsLCD(RX_Buff);

UART_RX_Flag = 0 ;
}
}
}


putsLCD(LCDString); <== 執行到這裡有顯示嗎?
ANS:有的 LCDString 有顯示出來!!
就是
if(UART_RX_Flag==1) // 判斷資料傳送狀態旗標
{
LCD_SetCursor( 0,0);
putsLCD(RX_Buff);

UART_RX_Flag = 0 ;
}
裡面沒執行出來,用中斷來檢查,結果是不能中斷!!
此外在執行debugger run中
觀察 View -> watch -> RX_Buff 一直為Reserved Memory
硬體方面 我有用示波器測量Pin31、DB2 確實有訊號進來
硬體接法:
DB3 -> T1OUT , T1IN -> Pin32
DB2 -> R1IN , R1OUT -> Pin31

Attach file:



jpg  (0.00 KB)


發表於: 2009/9/14 18:20

Edited by on 2009年09月14日 20:35:06
Edited by on 2009年09月14日 20:43:25
頂部


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


懇求各位前輩指點....
經過小弟數次修正及檢查後
個人覺得LCD顯示不出資料是因為 UART資料沒有進來的樣子(有用中斷來檢查)
所以厚著臉皮...再次來請教各位前輩..
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Module Name : GPS Receiver *
//DATE : 2009.08.11 *

*****************************************************************************/
// 在程式內設定 Configuration Bits 的範例
// 需注意 : 要參考 Header file 中的可用定義

#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) ;

#define INPUT 1
#define OUTPUT 0

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

char LCDString[] = "GPS Receive";

unsigned int ADC_TempValue ;

unsigned char DataAvailable ;

unsigned char RX_Temp,RX_Buff[90],LineCount = 0 ;
char cnt=0,i ;

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

void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void) // UART1接收資料中斷副程式
{
RX_Temp=RX_Buff[cnt]=ReadUART1(); // Get RS-232 data 將UART讀取資料暫存器的內容讀出
UART_RX_Flag = 1 ;

IFS0bits.U1RXIF = 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() ;

while(1)
{
LCD_SetCursor( 0,0);
putsLCD(LCDString);
if(UART_RX_Flag==1) // 判斷資料傳送狀態旗標
{
LCD_SetCursor( 0,0);
putsLCD(RX_Buff);

UART_RX_Flag = 0 ;
}
}
}

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"

int config1 , config2 ;

// ****************************************************
// 設定 UART1 RX = RP10 -> Pin31
// 設定 UART1 TX = RP17 -> Pin32
// ****************************************************
PPSUnLock ;

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;

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

void AD_Delay(void)
{
int LoopVar ;
int LoopVar2 , LoopVar3 ;

for ( LoopVar = 0 ; LoopVar < 100 ; LoopVar++ )
LoopVar2 = LoopVar3 + 1 ;

}

Attach file:



jpg  (0.00 KB)

Link only for registered users

發表於: 2009/9/13 21:49
頂部


Re: 程式燒入app020 plus的問題
#24
初級會員
初級會員


很抱歉....小弟愚笨
懇請告知 在哪邊將DSW6全部OFF??

發表於: 2009/9/10 21:23
頂部


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


不好意思...小弟愚昧...又失敗了
我使用
int main(void)
{

//省略

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

}
結果並沒有顯示任何東西,且迴圈只做一次就停止
====================================
使用
int main(void)
{

//省略

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

}
結果顯示1個黑色方塊(並非有8*5的黑色小點,而是8*5的黑色小點缺少2個黑色小點,也就是8*5的黑色方塊中有兩個白色的點)
====================================
小弟想請教會是
void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void) // UART1接收資料中斷副程式
{

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

IFS0bits.U1RXIF = 0 ;
}
出了問題嗎??我有用示波器量確實有訊號進來
另外Ryang版主所指點的
====================================
LCD_SetCursor(0,1) ;
putLCD(RxBuff[0]) ; // 先測一下 RxBuff[0], putrsLCD( ) 是送出 ROM 的字串,應該用 putLCD( ) 或 pursLCD( ) 才對
UART_RX_Flag=0;
====================================
我在我的LCD.c檔沒看到putLCD( ) & pursLCD( )
有LCD_PutChar()&putsLCD()
我使用putsLCD()在while(1)中並沒有顯示任何東西
使用LCD_PutChar()在while(1)中顯示黑色方塊
請問我使用LCD_PutChar()會是正確的嗎?

發表於: 2009/8/30 23:32
頂部


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


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

發表於: 2009/8/22 20:09
頂部


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


參照:

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

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

發表於: 2009/8/20 14:58
頂部


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


本人使用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
頂部


關於FAQ-問題與解答裡的PPS的說明及使用範例
#29
初級會員
初級會員


關於FAQ-問題與解答裡的PPS的說明及使用範例
本人使用後怎麼終端機上沒有任何顯示!!
UART出來的COMPORT有抓到(非沒有灌區動程式的關係及終端機的COM抓錯)
我使用PIC24FJ128GB106將pin31接到JP21的DB-2,pin32接到JP21的DB-3
程式編譯及燒錄均無錯誤
程式是PPS的使用範例
我有哪一步做錯嗎??
P.S.2009 暑期菁英班課堂教材的Microchip 16-bit MCU PPS Module .pdf 教材 出現404 檔案似乎有問題 不能下載

發表於: 2009/7/28 23:41
頂部


Re: 請問PIC24FJ128GB106如何取出USB的資料?
#30
初級會員
初級會員


感謝~~calvin前輩 回答我的問題
我會認真的study 再次感謝calvin前輩!!

發表於: 2009/7/27 21:53
頂部



« 1 2 (3) 4 »



:::

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... ]

教育訓練中心

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