Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
初級會員
|
我該如何將命令加到我的asm source code中定義位址呢?
真是不好意思~請不吝解答,謝謝版大~ -------------------------------------------------- 我還是用我原來的方法好了,這個有機會再學~謝謝版大。
發表於: 2008/3/26 20:02
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
版主
|
int __attribute__ ((address(0x1000))) Mabonga = 1;
是說用 _ _ Attribute __((address(0x1000))) 將變數或查表資料強制放在位址 0x1000 的地方。用的就是 (address )的屬性宣告。
發表於: 2008/3/26 17:44
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
初級會員
|
目前用笨方法~就是用 .word 0xFFFF 把記憶區塊擠到1c00以後,但總覺得不太專業~ :p
發表於: 2008/3/26 15:24
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
版主
|
User's Guide 有說明 :
Likewise, to locate variable Mabonga at address 0x1000 in data memory: int __attribute__ ((address(0x1000))) Mabonga = 1; Another way to locate code or data is by placing the function or variable into a user-defined section, and specifying the starting address of that section in a custom linker script. This is done as follows: Modify the code or data declaration in the C source to specify a user-defined section. Add the user-defined section to a custom linker script file to specify the starting address of the section. For example, to locate the function PrintString at address 0x8000 in program memory, first declare the function as follows in the C source: int __attribute__((__section__(".myTextSection"))) PrintString(const char *s); The section attribute specifies that the function should be placed in a section named .myTextSection, rather than the default .text section. It does not specify where the user-defined section is to be located. That must be done in a custom linker script, as follows. Using the device-specific linker script as a base, add the following section definition: .myTextSection 0x8000 : { *(.myTextSection); } >program This specifies that the output file should contain a section named .myTextSection starting at location 0x8000 and containing all input sections named.myTextSection. Since, in this example, there is a single function PrintString in that section, then the function will be located at address 0x8000 in program memory. Similarly, to locate the variable Mabonga at address 0x1000 in data memory, first declare the variable as follows in the C source: int __attribute__((__section__(".myDataSection"))) Mabonga = 1; The section attribute specifies that the function should be placed in a section named .myDataSection, rather than the default .data section. It does not specify where the user-defined section is to be located. Again, that must be done in a custom linker script, as follows. Using the device-specific linker script as a base, add the following section definition: .myDataSection 0x1000 : { *(.myDataSection); } >data This specifies that the output file should contain a section named.myDataSection starting at location 0x1000 and containing all input sections named.myDataSection. Since, in this example, there is a single variable Mabonga in that section, then the variable will be located at address 0x1000 in data memory.
發表於: 2008/3/26 9:54
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
初級會員
|
豁出去了,我打算保留512指令字元在程式最後區段1C00-1FFF來存我需要存的幾個參數,清掉也沒關係,可以從ram載入。
新問題,我要如何將要記憶的參數定義於程式區段1C00-1FFF? 麻煩版大幫我解答,謝謝~ 問題兒童,請多包涵~
發表於: 2008/3/26 9:39
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
版主
|
如果要儲存一個被 Erase 的 Image,那就麻煩了。如果是要更新程式而不用管舊的內容值那就簡單多了。在這小IC裡要模擬 EEPROM 的話就有諸多限制,可否考慮用外加的 SPI (25LCxx) 或 I2C (24LCxx) 的串列型 EEPROM。這些 EEPROM 的價格爛到不行了。
發表於: 2008/3/26 8:58
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
初級會員
|
算錯 512指令字元=1536 bytes 這顆cpu好像只有1024byte RAM,是不是根本沒機會~ >"<
發表於: 2008/3/25 21:07
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
初級會員
|
感謝版大解答,不過真糟糕,我都用組合寫,因為能節省程式碼,若ROM夠大,才會考慮用C寫。
我的新問題,ERASE FLASH最小區塊為512指令字元,沒辦法更小嗎,512指令字元,我必須以768位元組來做IMAGE,很恐怖吧,24HJ12GP202這顆這麼小,這一清,佔了1/8程式碼,會要了它的命,請問版大,有好的方法嗎? 謝謝~ nvmcon=0x404f =>清除0000~1FFE nvmcon=0x4042 =>清除page(512指令字元)
發表於: 2008/3/25 20:29
|
|||
|
Re: 請問24HJ12GP202如何把FLASH當EEPROM用?
|
||||
---|---|---|---|---|
版主
|
發表於: 2008/3/25 15:41
|
|||
|