Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
版主
|
題外話,
如果有詳細看 dsPIC30F Family Reference Manual 裡的 UART 章節的話對周邊的設定就會比較清楚,查一下也會了解那個位元 Default 的值為0,所以這個參數搞不過就不用設它也行,因為 Data Sheet 說它開機是 0 的設定。 UTXBRK : R/W-0 (標示為該位元是可讀、可寫入的位元,Reset 後的 Default 值為 0) 像 TRMT 位元標示 : R-1 (表示該位元只能做讀取的功能,default 值為 1 )
發表於: 2010/1/12 10:11
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
資深會員
|
修改 support\peripheral_30F_24H_33F目錄下的uart.h,使得dsPIC30F4011定義在UART_V1下,C30編譯成功.
感謝Ryang版主的幫助及其他網友不厭其煩的指教,今天可以有個好眠了!
發表於: 2010/1/11 20:32
Edited by cct1210 on 2010年01月11日 20:58:33
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
版主
|
那就是定義錯了,dsPIC30F4011 的 UART 是屬於舊的架構,不會與 dsPIC33F/PIC24H 使用相同的架構的。所以是 Microchip 在新版的C30 V3.22 又被抓包了,通融一下 uart.h 改一下讓它成為 V1 的定義。
發表於: 2010/1/11 16:32
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
資深會員
|
我找到UART.H的定義,在第35行定義如下,
#if defined(__dsPIC33F__) || defined(__PIC24H__) || \ defined(__dsPIC30F1010__) || defined(__dsPIC30F2020__) || defined(__dsPIC30F2023__) || defined(__dsPIC30F4011__) #define _UART_V2 #elif defined(__dsPIC30F__) #define _UART_V1 #endif 看起來dsPIC30F4011是定義在_UART_V2,不是在_UART_V1 Ryang版主,看起來新版本V3.22(V3.20b亦是)跟你的V3.12有很大的不同,就是差很大.
發表於: 2010/1/11 16:02
Edited by cct1210 on 2010年01月11日 21:07:03
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
資深會員
|
附上程式主檔test.c
個人使用MPLAB8.4, C30 V3.22 當device選dsPIC30f6010a,可編譯,選dsPIC30f4011,則就會出現編譯錯誤. Attach file: Link only for registered users
發表於: 2010/1/11 15:43
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
版主
|
回覆 cct1210 :
我使用的 C30 是 V3.12 的版本,在其 uart.h 檔案裡的宣告 dsPIC30F4011 是屬於 UART_V1 的架構有別於底下的 V2 架構。
#if defined(__dsPIC33F__) || defined(__PIC24H__) ||
我有在 V1 的 uart.h 檔裡找到 "UART_TX_PIN_NORMAL" 的定義,我不知道位何你的版本會找不到,麻煩在檢查一下 uart.h 檔的相關宣告。 底下為 uart.h 對此位元的宣告,一般是要設成NORMAL (=0) 的,開機的 default 也是設為 0 的,如果強設為 1 的話則可將 TxD 腳拉成 Low 輸出直到將該位元清為 0,該位元主要設給Lin Bus 送出 Break Signal 功能用,一般的UART 的模式下不會用到此功能。 #define UART_TX_PIN_NORMAL 0xF7FF /* UART TX pin operates normally */ #define UART_TX_PIN_LOW 0xFFFF /* UART TX pin driven low */
發表於: 2010/1/11 11:27
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
資深會員
|
請看以下程式,主要是從C30的docs\periph_lib\dsPIC30F_dsPIC33F_PIC24H_UART_Help.htm抄下來的
#include<p30fxxxx.h> #include<uart.h> /* Received data is stored in array Buf */ char Buf[80]; char * Receiveddata = Buf; /* This is UART1 transmit ISR */ void __attribute__((__interrupt__)) _U1TXInterrupt(void) { IFS0bits.U1TXIF = 0; } /* This is UART1 receive ISR */ void __attribute__((__interrupt__)) _U1RXInterrupt(void) { IFS0bits.U1RXIF = 0; /* Read the receive buffer till atleast one or more character can be read */ while( DataRdyUART1()) { ( *( Receiveddata)++) = ReadUART1(); } } int main(void) { /* Data to be transmitted using UART communication module */ char Txdata[] = "Microchip"; /* 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); /* Configure UART1 module to transmit 8 bit data with one stopbit. Also Enable loopback mode */ baudvalue = 5; U1MODEvalue = UART_EN & UART_IDLE_CON & UART_DIS_WAKE & UART_EN_LOOPBACK & UART_EN_ABAUD & UART_NO_PAR_8BIT & UART_1STOPBIT; U1STAvalue = UART_INT_TX_BUF_EMPTY & UART_TX_PIN_NORMAL & UART_TX_ENABLE & UART_INT_RX_3_4_FUL & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR; OpenUART1(U1MODEvalue, U1STAvalue, baudvalue); /* Load transmit buffer and transmit the same till null character is encountered */ putsUART1 ((unsigned int *)Txdata); /* Wait for transmission to complete */ while(BusyUART1()); /* Read all the data remaining in receive buffer which are unread */ while(DataRdyUART1()) { (*( Receiveddata)++) = ReadUART1() ; } /* Turn off UART1 module */ CloseUART1(); return 0; } 若在MPLAB的Select devices選dsPIC30F6010A則可以編譯通過,若選擇dsPIC30F4011編譯則出現error: 'UART_TX_PIN_NORMAL' undeclared (first use in this function) ,所以跟是不是使用"USE_AND_OR" 一點關係也沒有,覺得有點風馬牛不相及. 個人有點困惑,從出現的訊息"UART_TX_PIN_NORMAL' undeclared,應該是此定義(應該是使用#define 所定義),在dsPIC30F4011的head檔被刪掉了(什麼原因就不得而知???,因為在V3.02C還在,V3.20B不見了),而在dsPIC30F6010A內還保留著,想起來有點可怕,都沒說原因就不見了,我以前的很多程式,不明不白地就不能動了. 希望有人可解答我的問題,是不是我那裡搞錯了,真希望我錯了,這樣我才能安心.
發表於: 2010/1/9 0:47
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
版主
|
我還沒安裝 C30 v3.20 版本,不過找一下 "USE_AND_OR" 的定義行是否有備註解掉就知道的。
基本上 "USE_AND_OR" 沒有定義的話就會使用 & 的運算,而以前所寫的練習也都是以 & 的運算元為主的。 如 Timer 的編譯有相同問題就找一下。
發表於: 2010/1/8 18:02
|
|||
|
Re: 舊版本C30可編譯,新版本的C30編譯不會過問題求教?
|
||||
---|---|---|---|---|
資深會員
|
參照:
我使用V3.20版 有改回來 但是還是不行 執行上述函式庫還是會有問題 "燒錄後" 我有一產品使用V2.4 後來要降低成本改dsPIC33FJ 升級到V3.20但是舊產品有問題 現在PC 灌2個XP 1個使用V2.4 1個使用V3.20 真麻煩 後來dsPIC33FJ 就不用函式庫宣告 少掉麻煩
發表於: 2010/1/8 15:03
|
|||
==== ^^ ^^ ====
|
||||
|