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


Browsing this Thread:   1 Anonymous Users






Re: 請問幾個關於 PIC24FJ256GA108 的問題
#5
版主
版主


查看用戶資訊
參照:
問題三 :
如果 Device 選的是 PIC24FJ64GA008 時, 不會有 PORTG 不能使用的問題, 但是同一組 PORT 各位元會互相干擾, 例如下面程式, nLCD_CS = 0, 隨後當 LCD_RS = 0 的時候, nLCD_CS 會自己變成 1 . PORTE and PORTF 也會有相同的問題

這種同一個 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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問幾個關於 PIC24FJ256GA108 的問題
#4
新會員
新會員


查看用戶資訊
Chun-Hao 兄:
謝謝您的提示, 當 Compile 出現關於 RG0, RG1 的錯誤訊息時, 第一時間想當然爾就是看看 p24FJ256GA108.h 是不是少定義了什麼, 只是不知道當時是否是鬼遮眼, 看到對於 PORTG 的宣告並沒有異常(我想我可能看錯檔案吧), 經您的提示再次看了一下 p24FJ256GA108.h, 果然如您所言, 發現自己很白痴, 現已將 RG0, RG1 補上, 解決了此一問題. 謝謝您~
但是問題三, 仍然沒有發現問題所在, 不知您是否能再給些提示, 在此先謝啦!

C_H_M 兄:
謝謝您說明的如此詳細, 剛剛已經用您的方式解決了 constant data > 32K bytes 的問題, 非常的謝謝您~

發表於: 2008/7/26 17:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問幾個關於 PIC24FJ256GA108 的問題
#3
中級會員
中級會員


查看用戶資訊
當要使用更大量的 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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問幾個關於 PIC24FJ256GA108 的問題
#2
新會員
新會員


查看用戶資訊
問題1:
答:我以前遇過這個問題了,原廠的提供方式是用Table的方式讀取,但是我那時是用外部EEPROM取代。
問題二與問題三:
一樣的問題,答案在 p24FJ256GA108.h 裡面,你自己去看看,練習一下找答案的能力,你就會發現自己很白痴,因為我們都有惰性,而且我也白痴過一次,但是我自己從裡面找到答案

發表於: 2008/7/26 8:58
《佛說人有二十難》
貧窮布施難 豪貴學道難 棄命必死難 得睹佛經難
生值佛世難 忍色忍欲難 見好不求難 被辱不瞋難
有勢不臨難 觸事無心難 廣學博究難 除滅我慢難
不輕未學難 心行平等難
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問幾個關於 PIC24FJ256GA108 的問題
#1
新會員
新會員


查看用戶資訊
請問幾個關於 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
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... ]

教育訓練中心

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