Re: 想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)
|
||||
---|---|---|---|---|
新會員
|
View菜单里能看到Porgram Memory,我在ICD2 DEBUG下面看FLASH内容,也是不对的!但用AN1095就OK,看来好好研究下AN1095是正解,谢谢!
發表於: 2009/6/24 2:37
|
|||
|
Re: 想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)
|
||||
---|---|---|---|---|
版主
|
仿真時是修改片上的 Flash 的,而 LPLAB IDE 下的 Program Window 是不會被修改到的,要看到被修改過的 Flash 內容就須將片上的東西讀回 MPLAB IDE 。所以請用 ICD2 下的 Read Target Device 的圖示讀回後顯示。
發表於: 2009/6/23 15:06
|
|||
|
Re: 想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)
|
||||
---|---|---|---|---|
新會員
|
_WritePM:
mov W0,W2 mov W1,W3 mov #tblpage(_c_f),w0 mov w0,TBLPAG mov #tbloffset(_c_f),w0 TBLWTL W2,[W0] TBLWTH W3,[W0++] MOV #0x4003,W0 MOV W0,NVMCON PUSH SR MOV #0x00E0,W0 IOR SR mov #0x55,W0 mov W0, NVMKEY mov #0xAA, W0 mov W0, NVMKEY bset NVMCON, #15 nop nop btsc NVMCON, #15 bra $-2 pop SR return 使用以上代码,用W0、W1来传递两个字参数,来写FLASH中的24位,在仿真时结果不正确,代码是参照FRM中Section 5 "FLASH Programming"中的示例代码,对一个WORD的FLASH区域进行编程。对于这部分有用AN1095中的代码进行操作仿真正确,不得其解,谢谢帮助!
發表於: 2009/6/21 14:25
|
|||
|
Re: 想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)
|
||||
---|---|---|---|---|
版主
|
要修改 Flash Memory 是要透過 builtin Function 來取得 Talbe-Page & Table-Offset 的,此外還要使用 in-line assembly 的語法來做 Table Write 及 NVMKEY Register 的解鎖步驟。還有 Flash 一次就是一個區塊的清除,要寫入前就必須對寫入的區塊作 Block Erase 的動作。建議你看一下 dsPIC33F Family Reference Guide 裡的 Flash Memory Section.
底下是 dsPIC30F 的 EEPROM 的教育訓練課程,可以先砍一下,方法與dsPIC33F 的 Flash 類似: http://www.microchip.com.tw/modules/w ... glefile.php?cid=4&lid=229 AN1094 Bootloader 可以參考一下是怎樣改 Flash 的: http://www.microchip.com/stellent/idc ... eId=1824&appnote=en533154 http://www.microchip.com/stellent/idc ... eId=1824&appnote=en530200
發表於: 2009/6/19 14:21
|
|||
|
想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)
|
||||
---|---|---|---|---|
新會員
|
想通过__builtin_函数改变dsPIC33里面的const常量值,下列方式可以吗(附简单程序)??
typedef union { float fl; uint16 x[2]; }un_fl; char str_tmp[10]; const un_fl adcK = {3.14}; un_fl adcK_t = {5.24}; int main() { uint16 lowWord,highWord; int tbloffset; un_fl adcK_tmp; adcK_tmp = adcK; adcK_tmp.fl = 5.42; TBLPAG = __builtin_tblpage(&adcK); tbloffset = __builtin_tbloffset(&adcK); lowWord = __builtin_tblrdl(tbloffset); highWord = __builtin_tblrdl(tbloffset+2); //__builtin_write_NVM(); printf("%.2f\n",adcK.fl); TBLPAG = __builtin_tblpage(&adcK); tbloffset = __builtin_tbloffset(&adcK); __builtin_tblwtl(tbloffset,adcK_t.x[0]); __builtin_tblwtl(tbloffset+2,adcK_t.x[1]); printf("%.2f\n",adcK.fl); while(1); return 0; }
發表於: 2009/6/18 21:22
|
|||
|