Re: 請問幾個關於 PIC24FJ256GA108 的問題
|
||||
---|---|---|---|---|
版主
|
參照:
問題三 : 這種同一個 PORT 位元相互干擾的問題稱之為 Read-Mpdify-Write 主要是因為 Pipelining 的動作導致I/O因寄生電容的Delay造成回讀 PORT 時的誤動作。解決方式可以再對同一PORT連續動作時中間插入ㄧ個 Nop( ); 指令或在做讀取動作時不要對 PORTx 動作請改成讀取 LATx 的方式。同樣寫入已是可以直接使用 LATx 來取代 PORTx. http://www.microchip.com.tw/modules/n ... t_id=21150#forumpost21150 http://www.microchip.com.tw/modules/n ... t_id=18255#forumpost18255
發表於: 2008/7/29 14:20
|
|||
|
Re: 請問幾個關於 PIC24FJ256GA108 的問題
|
||||
---|---|---|---|---|
中級會員
|
當要使用更大量的 const 資料時, 宣告 const 資料時請指定放入 program 的區域中,
如下所示, 可以不受 PSV 範圍的限制. *** 但是讀取資料亦不受 PSV 讀取協助, 請使用 tblrdl 方式來讀取 *** 又或者你的 RAM 有足夠空間時, *** 先行以 _memcpy_p2d16(void *dest, _prog_addressT src, unsigned int len) 複製到 RAM 宣告 const 放入 program 區域中 const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; ---------------------------------------------------------------------------------- 使用 _memcpy_p2d16(void *dest, _prog_addressT src, unsigned int len) 複製到 RAM #include "p24fj128ga108.h" #include "libpic30.h" const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; _prog_addressT const_ptr; unsigned int __attribute__((__far__)) const_temp[4096]; int main(void) { _init_prog_address(const_ptr, const_1); // 取得 const_1 的存放位址於 const_ptr _memcpy_p2d16(const_temp, const_ptr, sizeof(const_1)); // 將 const_1 的內容複製到 RAM 中 return 0; } ----------------------------------------------------------------------------------- 使用 tblrdl 的方式來讀取 const 資料內容 #include "p24fj128ga108.h" #include "libpic30.h" #define mem_const_int(const_value,const_p) \ { TBLPAG = const_p >> 16; \ WREG1 = const_p & 0xFFFF; \ asm("TBLRDL.W [W1],W2"); \ const_value = WREG2; \ const_p += 2; } #define mem_const_char(const_value,const_p) \ { TBLPAG = const_p >> 16; \ WREG1 = const_p & 0xFFFF; \ asm("TBLRDL.B [W1],W2"); \ const_value = WREG2 & 0xFF; \ const_p ++; } const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; _prog_addressT const_index; unsigned int const_get; int main(void) { // 先取得 const_1 的位址放在 const_index 中, 以便接著順序取得 const 資料 _init_prog_address(const_index, const_1); // 呼叫 mem_const_int(const_get, const_index), 會依序取得 const_1 的資料內容 [0], [1], [2].... mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); return 0; }
發表於: 2008/7/26 15:49
|
|||
|
Re: 請問幾個關於 PIC24FJ256GA108 的問題
|
||||
---|---|---|---|---|
新會員
|
問題1:
答:我以前遇過這個問題了,原廠的提供方式是用Table的方式讀取,但是我那時是用外部EEPROM取代。 問題二與問題三: 一樣的問題,答案在 p24FJ256GA108.h 裡面,你自己去看看,練習一下找答案的能力,你就會發現自己很白痴,因為我們都有惰性,而且我也白痴過一次,但是我自己從裡面找到答案
發表於: 2008/7/26 8:58
|
|||
《佛說人有二十難》
貧窮布施難 豪貴學道難 棄命必死難 得睹佛經難 生值佛世難 忍色忍欲難 見好不求難 被辱不瞋難 有勢不臨難 觸事無心難 廣學博究難 除滅我慢難 不輕未學難 心行平等難 |
||||
|
請問幾個關於 PIC24FJ256GA108 的問題
|
||||
---|---|---|---|---|
新會員
|
請問幾個關於 PIC24FJ256GA108 的問題, 附上原始程式, 附件有整個 porject.
目前使用 MPLAB IDE 8.14 and MPLAB C30 Version v3_02 問題一 : 當 constant data 大於 32 K bytes 時, Compile 會出現下列錯誤訊息, c:\program files\microchip\mplab c30\bin\pic30-coff-ld.exe: Error: PSV section .const exceeds 32K bytes (actual size = 33280). c:/program files/microchip/mplab c30/bin/../lib\libpic30-coff.a(crt0.o)(.init+0x16):../support/inc/p30f2010.inc: Link Error: relocation truncated to fit: WORD _const_length 問題二 : 當使用到 PORTG 時, 會出現下列錯誤訊息 const.c:60: error: 'PORTGBITS' has no member named 'RG0' 問題三 : 如果 Device 選的是 PIC24FJ64GA008 時, 不會有 PORTG 不能使用的問題, 但是同一組 PORT 各位元會互相干擾, 例如下面程式, nLCD_CS = 0, 隨後當 LCD_RS = 0 的時候, nLCD_CS 會自己變成 1 . PORTE and PORTF 也會有相同的問題 #include <P24FXXXX.h> #define nLCD_CS PORTGbits.RG0 #define LCD_RS PORTGbits.RG1 #define nLCD_WR PORTFbits.RF1 #define nLCD_RD PORTFbits.RF0 #define nLCD_RST PORTFbits.RF6 #define LCD_Light PORTFbits.RF7 const unsigned int icon_wave_0[0x3000] = { 0x280F, 0x0002, 0xFFFF, 0xF800, 0x0000, 0x003E, 0x0000, 0xFF80, 0x0000, 0xC000, 0x01FF, 0x0000, 0xFFE0, 0x0003, 0xE000, 0x03C1, 0x0000, 0x99F0, 0x0007, 0xF000, 0x07FC, 0x0000, 0xFCF0, 0x0007, 0xF000, 0x07FC, 0x0000, 0xFCF0, 0x0007, 0xE000, 0x0399, 0x0000, 0xC1E0, 0x0003, 0xC000, 0x01FF, 0x0000, 0xFF80, 0x0000, 0x0000, 0x003E, 0x0000}; const unsigned int icon_wave_1[0x1100] = { 0x280F, 0x0002, 0xFFFF, 0xF800, 0x0000, 0x003E, 0x0000, 0xFF80, 0x0000, 0xC000, 0x01FF, 0x0000, 0xFFE0, 0x0003, 0xE000, 0x03C1, 0x0000, 0x99F0, 0x0007, 0xF000, 0x07FC, 0x0000, 0xFCF0, 0x0007, 0xF000, 0x07FC, 0x0000, 0xFCF0, 0x0007, 0xE000, 0x0399, 0x0000, 0xC1E0, 0x0003, 0xC000, 0x01FF, 0x0000, 0xFF80, 0x0000, 0x0000, 0x003E, 0x0000}; void InitIO (void) { TRISA = 0x0000; PORTA = 0x0000; TRISB = 0x0F3F; PORTB = 0x0F3F; TRISC = 0x0000; PORTC = 0x0000; TRISD = 0x0000; PORTD = 0x0000; TRISE = 0x0300; PORTE = 0x0300; TRISF = 0x0004; PORTF = 0x00C7; TRISG = 0x0080; PORTG = 0x028F; } void Delay_ms (unsigned int dt) { unsigned int i; for (;dt>0;dt--) for (i=0;i<1000;i++); } int main (void) { InitIO(); while (1) { nLCD_CS = 0; LCD_RS = 0; nLCD_WR = 0; nLCD_WR = 1; LCD_RS = 1; nLCD_WR = 0; nLCD_WR = 1; nLCD_CS = 1; Delay_ms(1); }; while(1); } Attach file: Link only for registered users
發表於: 2008/7/25 13:57
|
|||
|