• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
  • slider image 491
:::

論壇索引


Board index » All Posts (maxrobert)




關於震盪器問題
#1
新會員
新會員


我是使用模擬版APP020有參考曾百由老師的書上範例,關於UART範例問題,因為APP020是使用7.3728MHz的震盪器,所以他範例包率產生器數值為
/* Setup the Buad Rate Generator */
baudvalue = 95;
//UxBRG = ( (FCY/Desired Baud Rate)/16) – 1
//UxBRG = ( (7372800*2/9600)/16-1) = 95
那我如果要自己做電路板但是震盪器選用7.2MHz時,包率產生器值是要改成為
baudvalue = 92.75;
//UxBRG = ( (7200000*2/9600)/16-1) = 92.75
這樣改為小數沒問題嗎?
謝謝!!!

發表於: 2009/2/10 20:26
頂部


dsPIC30F4011與ZigBee問題
#2
新會員
新會員


小弟之前一直使用dsPIC30F4011這顆PIC,現在想要加上ZigBee無線功能,正好有看到MRF24J40MA這顆,所以想請問可以使用dsPIC30F4011搭配MRF24J40MA嗎???謝謝!!!

發表於: 2009/1/7 22:04
頂部


Re: UART範例程式問題
#3
新會員
新會員


想再請教一下板主,如果我現在動作是傳1這個單一字元進來給PIC接收,讓我的LED1亮,我判別式是這樣寫
if(Rec_Buffer==0x31)
{
LED1 = 0;
}
動作沒問題,那如果我現在是要傳10這字串的話,那我判別式是這樣寫嗎?
if(Rec_Buffer==0x31&&030)
{
LED1 = 0;
}
然後我原本讀取Rec_Buffer是這樣寫
Rec_Buffer = ReadUART1( );
那要改成字串的話是要改成這樣嗎?
Rec_Buffer = getsUART1( );
不好意思一直麻煩版主!!!

發表於: 2008/10/23 21:09
頂部


Re: UART範例程式問題
#4
新會員
新會員


想在請問一下板主,因為我是用APP020學習板,例如我要從LabVIEW傳個100的字串给PIC,然後要讓APP020的LED1亮,再傳個101的字串就讓LED1滅,想請問版主我要如何去抓這些字串,我是想利用你的程式去改,我執行結果就是當我LabVIEW不管傳什麼值都只會讓LED1亮,我抓取字串程式如下,其他程式都參照範例程式

while (1)
{
while ( !Rec_Flag) ;

Rec_Flag=0;

putcLCD(Rec_Buffer);
Rec_Count++;
if (Rec_Count>=3)
{
setcurLCD(0,1) ;
Rec_Count=0;
}
if(Rec_Buffer==100);
{
LED1 = 0;
}
if(Rec_Buffer==101);
{
LED1 = 1;
}
}
}

發表於: 2008/10/20 20:56
頂部


Re: UART範例程式問題
#5
新會員
新會員


感謝版主的熱心回答,想在請教一下板主if (Rec_Count>=16)的Rec_Count是代表什麼意思?還有就是我現在只要接受到電腦傳來的字,那就只要

putcLCD(Rec_Buffer);
Rec_Count++;
if (Rec_Count>=16)
{
setcurLCD(0,1) ;
Rec_Count=0;
}
就可以了嗎?也麻煩可以解釋一下這段程式的動作嗎?謝謝!!!

發表於: 2008/10/16 19:32
頂部


UART範例程式問題
#6
新會員
新會員


想請教各位前輩,小弟有在下載中心下載課程裡的一個關於UART的範例程式,範例程式如下,想請教關於下列兩行紅色部份是表示什麼,還有小弟是個新手想請教一下Rec_Buffer是代表讀取由電腦傳來的值嗎?謝謝!!!
/************************************************************/
/*                                                             */
/*                       EUART Lab 1                            */
/*                                                             */
/* Note:                                                    */
/*        DSW1 – SW1 & SW2 are ON position for the ICD2         */
/*             programming & using the PGC, PGD for Debug    */
/*        DSW2 – SW1 & SW2 are ON position for UART1 (Lab1)    */
/*             SW3 & SW4 are OFF position for Dis UART2     */
/*        DSW3 – SW1 & SW2 are ON position for VR input        */
/*        DSW4 – All OFF position                                */
/************************************************************/
//
#include     <p30fxxxx.h>
#include     "C30EVM_LCD.h"            // 將LCD函式的原型宣告檔案含入 
#include     <uart.h>                // 將UART函式的原型宣告檔案含入 
#include    <Stdio.h>
#include     <math.h>

void    Test_UART(void);
void    Init_UART(void);

const 
char    UART_LCD1[]="* Test UART 1 * " ;
const 
char    UART_LCD2[]="Send a float out" ;
const 
char  UART_LCD3[]=" Received UART1 " ;
const 
char  UART_LCD4[]="                " ;
const 
char  UART_LCD5[]="Press 'Enter' ??" ;

float Sin_A;
char Rec_Buffer=0;
char Rec_Flag=0;
char Rec_Count=0;
#define PI 3.14159

       
_FOSC(CSW_FSCM_OFF XT_PLL8);   //    XT with 8xPLL oscillator, Failsafe clock off
       
_FWDT(WDT_OFF);                  //    Watchdog timer disabled
      
_FBORPOR(PBOR_OFF MCLR_EN);    //    Brown-out reset disabled, MCLR reset enabled
       
_FGS(CODE_PROT_OFF);             //    Code protect disabled

void _ISR _U1RXInterrupt(void)
{
    
Rec_Buffer ReadUART1( );      // Read data from Receiver FIFO
    
Rec_Flag 1;                      // Set the Received Flag
    
IFS0bits.U1RXIF ;            // Clear Interrupt Flag
}


int    mainvoid )
{
    [
color=CC0000]SRbits.IPL=4;[/color]

    
OpenLCD( ) ;                    // 使用 OpenLCD( )對 LCD 模組作初始化設定
    
Test_UART( );                    // UART 模組測試程式
}

void Test_UART(void )
{
    
unsigned char n;

    
Init_UART( ) ;                                        // 對 UART 模組作初始化設定

    
printf("x1b[2J");

    
setcurLCD(0,0) ;                                    // 使用 setcurLCD( ) 設定游標於 (0,0)
    
putrsLCDUART_LCD1 ) ;
    
setcurLCD(0,1) ;                                    // 使用 setcurLCD( ) 設定游標於 (0,1)
    
putrsLCDUART_LCD2 ) ;

    
printf("************************************************************rn");
    
printf("*    Microchip Workshop RTC Training         Exercise 1 :  *rn");
    
printf("*    Please send the folat value form SIN 0 ~ 180 deg      *rn");
    
printf("************************************************************rn");

    for    (
n=0;n<190;n+=10)
    {
        
Sin_A sinf((n*PI)/180);
        
printf("     SIN %3d deg = %fnr",n,Sin_A);
    }

    
setcurLCD(0,1) ;                                    // 使用 setcurLCD( ) 設定游標於 (0,1)
    
putrsLCDUART_LCD5 ) ;


        while (
1)
        {
            while ( !
Rec_Flag) ;

            
Rec_Flag=0;
            if ([
color=CC0000]Rec_Buffer==0x0d[/color])
                {
                    
setcurLCD(0,0) ;
                    
putrsLCDUART_LCD3 ) ;  
                    
setcurLCD(0,1) ;
                    
putrsLCDUART_LCD4 ) ; //Clear Line 2 of LCD
                    
setcurLCD(0,1) ;
                    
Rec_Count=0;
                }
            else
                {    
                    
putcLCD(Rec_Buffer);
                    
Rec_Count++; 
                    if (
Rec_Count>=16)
                    {
                        
setcurLCD(0,1) ;
                        
Rec_Count=0;
                    }
                }
        
        }
}

/***********************************************/
// Subroutine to initialize UART module

void    Init_UART(void)
{
    
/* Holds the value of baud register */
    
unsigned int baudvalue;
    
/* Holds the value of uart config reg */
    
unsigned int U1MODEvalue;
    
/* Holds the information regarding uart
    TX & RX interrupt modes */
    
unsigned int U1STAvalue;
    
/* Turn off UART1module */
    
CloseUART1();
    
/* Configure uart1 receive and transmit interrupt */
    
ConfigIntUART1(UART_RX_INT_EN UART_RX_INT_PR6 &
    
UART_TX_INT_DIS UART_TX_INT_PR2);
    
/* Setup the Buad Rate Generator */
    
baudvalue 95;            //UxBRG = ( (FCY/Desired Baud Rate)/16) – 1
                            //UxBRG = ( (7372800*2/9600)/16-1) = 95
    /* Configure UART1 module to transmit 8 bit data with one stopbit.
    Also Enable loopback mode */
    
U1MODEvalue UART_EN UART_IDLE_CON &
                
UART_DIS_WAKE UART_DIS_LOOPBACK &
                
UART_DIS_ABAUD UART_NO_PAR_8BIT &
                
UART_1STOPBIT UART_ALTRX_ALTTX;
    
U1STAvalue UART_INT_TX_BUF_EMPTY &
                
UART_TX_PIN_NORMAL &
                
UART_TX_ENABLE UART_INT_RX_CHAR &
                
UART_ADR_DETECT_DIS &
                
UART_RX_OVERRUN_CLEAR;
    
OpenUART1(U1MODEvalueU1STAvaluebaudvalue);

    return;

發表於: 2008/10/15 22:40

Edited by Ryang on 2008年10月16日 09:21:45
Edited by Ryang on 2008年10月16日 09:22:20
頂部


Re: UART問題
#7
新會員
新會員


感謝前輩詳細的回答,謝謝!!!

發表於: 2008/10/15 15:43
頂部


UART問題
#8
新會員
新會員


想請教各位前輩,關於UART設定裡的U1MODEvalue=UART_ALTRX_ALTTX,請問UART_ALTRX_ALTTX是代表設定什麼功能?因為我看曾百由老師寫的書裡面沒有提到,謝謝!!!

發表於: 2008/10/14 15:48
頂部


dsPIC30F4011的AD轉換問題
#9
新會員
新會員


想請問dsPIC30F4011的AD轉換有手動觸發跟自動觸發是有什麼差別,謝謝!!!

發表於: 2008/7/23 22:53
頂部


關於APP020的類比轉數位問題
#10
新會員
新會員


想請問我現在已經寫了一個程式,當SW5按一下時LED1會亮再按一下SW5時LED1會暗,想請問我還要再加上設定兩段電壓範圍來控制LED1的亮跟暗,當在電壓範圍一4V到4.1V時LED1要暗,當在電壓範圍二2V到3V時要亮,我是利用PIC30F4011的AN0腳位來當類比輸入,以下是我的程式,我編譯時沒問題,執行動作時按SW5時動作都正常,可是電壓不同時沒有改變,以下主要部分為類比轉數位輸入時的程式,想請教各位前輩幫小弟看一下類比轉數位的程式有何問題,謝謝!!!PS(.....為我按SW5控制LED1的程式為求版面簡潔所以就沒放
#define __dsPIC30F4011__
#include <p30F4011.h>
#define LED1 LATEbits.LATE0
#define DIR_LED1 TRISEbits.TRISE0
#define SW5 PORTEbits.RE8
#define DIR_SW5 TRISEbits.TRISE8
#define INPUT 1
#define OUTPUT 0
#define LED_DATA LATE
void InitADC10(void);
void ADCCON(void);
int main(void )

{
InitADC10();
ADCCON();
DIR_LED1 = OUTPUT ;
DIR_SW5 = INPUT ;
LED_DATA = 0xffff ;

while (1)
{……..
………
………..
} //End of While(1) Loop
}// End of main program}
//
void InitADC10(void)
{
ADPCFG = 0x0078;
ADCON1 = 0x026E;
ADCON2 = 0x0000;
ADCHS = 0x0000;
ADCON3 = 0x0003;
IFS0bits.ADIF = 0;
IEC0bits.ADIE = 1;
ADCON1bits.ADON = 1;
}
void ADCCON(void)
{
float ADC_Value;
ADC_Value = ADCBUF0;
if(( ADC_Value < 0x399 ) && ( ADC_Value > 0x333))
{ LED1 = 1 ; }
if (( ADC_Value < 0x266 ) && ( ADC_Value > 0x199))
{ LED1 = 0 ; }
}

發表於: 2008/6/17 20:14
頂部



(1) 2 »



:::

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

教育訓練中心

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