免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
返回列表 回復 發帖

PIC 偽指令__IDLOCS 程式碼加入版本用法

const uint8_t Ver[4] __at(0x8000)={0x01,0x02,0x03,0x04};
0x8000 請依USER ID 記憶體實際位址修改

------------------------------------------------------------

偽指令 _ _IDLOCS 可記錄相關訊息(為看文章方便性寫為_ _IDLOCS,正確為__IDLOCS)
實際用時於程式碼開頭增加  __IDLOCS 1234
之後進行編譯後燒入完成
操作讀取程式碼(Read traget Device)後,即可於MPLAB IDE 上   Configure ==>ID Memory...
上面會顯示 01020304
同理 __IDLOCS 4567 將會顯示04050607

---------------------相關參考資料---------------

idlocs
PIC 單片機中有一處非常特殊的標記單元。它獨立於任何其它記憶體,唯一的作用就是作為一個標記。此標記值無法用軟體讀到,讀取和寫入的方法只有通過程式設計器實現。此標記值沒有讀保護,你可以利用它存放程式的版本或日期等資訊。如果需要,則可以用虛擬指令
__idloc 在程式中定義具體的值。
__idloc 0x1234 ;設定晶片的標記值為0x1234,注意前面有兩個底線符

使用 _ _IDLOCS 虛擬指令設置來自MPASM 彙編器的ID 位元組。 每次重新編譯項目或重新裝載十六進位檔時,都將根據_ _IDLOCS 虛擬指令的值設置ID 單元。專案編譯以後使用ID memory 對話方塊手動設置的任何ID 值都將改寫專案設置的ID值。




2.2 ID Locations
A user may store identification information (ID) in four ID locations. The ID locations are mapped in [0x2000:0x2003]. It is recommended that the user use only the
seven Least Significant bits (LSb) of each ID location.Locations read out normally, even after code protection.The ID locations read out in an unscrambled fashion
after code protection is enabled. It is recommended that ID location is written as “xx xxxx xbbb bbbb” where‘bbb bbbb’ is ID information.
The 14 bits may be programmed, but only the LSbs are displayed by MPLAB® IDE. xxxx’s are “don’t care” bits as they won’t be read by MPLAB® IDE.


這個位是bit的意思,不是位置的意思

是這樣的,假設只有一個IDLOC

我們寫入的時候是0xF3 二進位 1111 0011

其實只有0xF3的低七位也就是0x73(二進位 111 0011)寫到了IDLOC中

讀出的時候,讀到的是14位值,高7位是沒有用的,全是0,低七位是0x73(二進位 00 0000 0111 0011),合起來就是0x0073

也就是說,你寫0xF3.0xF2讀到的是0x00 0x73 0x00 0x72
--------------------------------------------
組語使用IDLOCS  可寫0X1234
C語 使用IDLOC   只可寫0X34     ???

須再確認差異
返回列表