• 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: 關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#6
版主
版主


查看用戶資訊
建議向這種修改 EEPROM or Flash Memory 的程式,因 ICD2 無法自動更新其內容,所以要做 Refresh 的動作將目前 IC 裡的內容讀回 MPLAB IDE 後才會正確顯示。
所以可以建議先使用 MPLAB SIM 去做此 Debug 會比較簡單的。

發表於: 2008/4/11 16:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#5
新會員
新會員


查看用戶資訊
謝謝版主 已可使用
1.使用 VIEW PROGRAM MEMORY 並無法直接觀察FLASH 剛寫入的值
2. 其餘同版大所說

發表於: 2008/4/11 16:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#4
版主
版主


查看用戶資訊
從 PIC24FJ Family Reference Manual Section 4. Program Memory
http://www.microchip.com/stellent/idc ... Id=1335&dDocName=en026374
所指, 自我燒錄前須作一次 512 x 24-bit 的 Block Erase後才可以每次寫入 64 x 24-bit 的指令,而且寫入是先寫到 Holding Latch 裡,待下燒錄命令時才會將整個64 Words的指令一次寫進去。
你所提的範例只會寫入一個 Word,但其餘的 63 words 因為沒有設定其內容,但也會一併寫進去,只是不知其值為何。


底下是簡體体版的 Reference Manual 所剪下來的說明:
1. 读取程序存储器的8 行(512 条指令),并存储在数据RAM 中。
2. 用所需的新数据更新RAM 中的程序数据。
3. 擦除该区块:
a) 将NVMOP 位(NVMCOM<3:0>)设置为0010 以配置块擦除。将ERASE
(NVMCOM<6>)和WREN (NVMCOM<14>)位置1。
b) 将要擦除的块的起始地址写入TBLPAG 和W 寄存器。
c) 将55h 写入NVMKEY。
d) 将AAh 写入NVMKEY。
e) 将WR 位置1 (NVMCOM <15>)。擦除周期开始,在擦除周期中CPU 会暂停。当
擦除结束时, WR 位会自动清零。
4. 将数据RAM 中的前64 条指令写入程序存储缓冲器(见第4.5 节“写程序存储器”)。
5. 将程序块写入闪存存储器:
a) 将NVMOP 位设置为0001 以配置行编程。将ERASE 位清零,将WREN 位置1。
b) 将55h 写入NVMKEY。
c) 将AAh 写入NVMKEY。
d) 将WR 位置1。编程周期开始,在写周期中CPU 会暂停。写入闪存存储器结束时,WR
位会自动清零。
6. 通过递增TBLPAG 中的值,使用数据RAM 中的下一批可用的64 条指令重复步骤4 和5,
直到全部512 条指令写回闪存存储器中。

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


Re: 關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#3
新會員
新會員


查看用戶資訊
但版主 以下為DATA SHEET所寫
是否可僅寫入1 WORD資料
謝謝
4.6.2 PROGRAMMING A SINGLE WORD
OF FLASH PROGRAM MEMORY
If a Flash location has been erased, it can be programmed
using table write instructions to write an
instruction word (24-bit) into the write latch. The
TBLPAG register is loaded with the 8 Most Significant
Bytes of the Flash address. The TBLWTL and TBLWTH
instructions write the desired data into the write latches
and specify the lower 16 bits of the program memory
address to write to. To configure the NVMCON register
for a word write, set the NVMOP bits (NVMCON<3:0>)
to ‘0011’. The write is performed by executing the
unlock sequence and setting the WR bit (see
Example 4-4).
EXAMPLE 4-4: PROGRAMMING A SINGLE WORD OF FLASH PROGRAM MEMORY
; Setup a pointer to data Program Memory
MOV #tblpage(PROG_ADDR), W0 ;
MOV W0, TBLPAG ;Initialize PM Page Boundary SFR
MOV #tbloffset(PROG_ADDR), W0 ;Initialize a register with program memory address
MOV #LOW_WORD_N, W2 ;
MOV #HIGH_BYTE_N, W3 ;
TBLWTL W2, [W0] ; Write PM low word into program latch
TBLWTH W3, [W0++] ; Write PM high byte into program latch
; Setup NVMCON for programming one word to data Program Memory
MOV #0x4003, W0 ;
MOV W0, NVMCON ; Set NVMOP bits to 0011
DISI #5 ; Disable interrupts while the KEY sequence is written
MOV #0x55, W0 ; Write the key sequence
MOV W0, NVMKEY
MOV #0xAA, W0
MOV W0, NVMKEY
BSET NVMCON, #WR ; Start the write cycle
NOP ; 2 NOPs required after setting WR

發表於: 2008/4/10 8:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#2
版主
版主


查看用戶資訊
CE027 :
http://www.microchip.com/stellent/idc ... NextRow=&ssUserText=ce027

CE109 & CE209 for dsPIC33F & PIC24H Run-Time Self Programming

PIC24F 的 Flash Memory 讀的時候是可以自一個位址讀出資料,但寫的時候是一個小區塊的寫入,這要 Check 該元件的區塊大小,以 Table Write 寫入事先寫到 PIC24F 的暫存區裡,待整個區塊都寫入後才會正式燒錄到 Flash 裡,這一點是很重要的。

發表於: 2008/4/9 15:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於PIC24FJ16GA002 PROGRAM MEMORY 寫入問題
#1
新會員
新會員


查看用戶資訊
DWORD EE_Read (void )
{


DWORD_VAL temp;

TBLPAG = 0;

temp.word.LW = __builtin_tblrdl(0xA0);
temp.word.HW = __builtin_tblrdh(0x00);
return temp.Val;

}
可讀取到0X0000A0 的資料

但是並不能寫入資料到 Myvar 中
const unsigned int myVar = 0x0002;
void EE_Write(WORD page, WORD addrLo, WORD dataHi, WORD dataLo)
{
unsigned int TBLpage;
unsigned int varAddr;
TBLpage = __builtin_tblpage(&myVar);
TBLPAG = TBLpage;
varAddr = __builtin_tbloffset(&myVar);
__builtin_tblwtl(varAddr, 0xAA); //load data to write:
__builtin_tblwth(varAddr, 0xAA); //load data to write:
//0xAAAA
NVMCON = 0x4003; //NVM word write opcode
__builtin_write_NVM(); //unlock & set WR bit
asm("DISI #10");
while(NVMCONbits.WR == 1);
}

請問該如何做寫入動作並指定記憶體位置呢?
謝謝

發表於: 2008/4/8 22:59
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... ]

教育訓練中心

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