1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我在应用中使用了PIC24FJ128GC06。我想用一页的闪存(512字,1536字节)作为非易失性存储区来存储设置、配置和校准数据。我知道如何使用TBLPTRS读取和写入访问内存,以及如何擦除一个页面。但是,如何告诉编译器我已经分配/保留了这个页面,以便它不被使用或包含在构建空间中?我还可以使用编译器来使用AyOy属性或“const”指令预加载这个内存吗?任何帮助和代码示例将不胜感激。
以上来自于百度翻译 以下为原文 Hi, I am using the PIC24FJ128GC006 in an application. I would like to use one page of the flash memory (512 words, 1536 bytes) as a non volatile memory area to store setup, configuration and calibration data. I know how to access this memory using the TBLPTRs for read and write access and how to erase a single page. But, how do I inform the complier that I have allocated / reserved this page so that it is not used or included in the build space? Can I also use the compiler to 'preload' this memory using the __attributes or the 'const' directives? Any helps and code examples would be greatly appreciated. |
|
相关推荐
11个回答
|
|
也许手册会有帮助,搜索“持久对象”
以上来自于百度翻译 以下为原文 Maybe the manual would help, search for "Persistent Objects" |
|
|
|
您可能想使用微芯片的DEE仿真。寻找一个1095文斯
以上来自于百度翻译 以下为原文 You may want to use the DEE Emulation from microchip. search for AN 1095. Vince |
|
|
|
据我所知,“持久”控制是基于RAM的变量,以防止它们在启动代码中被初始化。我正在寻找一种分配空间、定位和初始化基于ROM的变量的方法。
以上来自于百度翻译 以下为原文 As far as I am aware the 'persistent' control is for ram based variable to prevent them being initialised during the start-up code. I am looking for a way of allocating space, locating and initialising ROM based variables |
|
|
|
|
|
|
|
你可以从数据表中找出写/读Flash(检查第6章)以及PIC24F参考手册中的DS3000 0915。其他选项如vjasinski所说。而不是滚动自己,有人已经完成了工作。AN1095应该覆盖你正在寻找的(使用Flash作为仿真EEPROM)
以上来自于百度翻译 以下为原文 You can either figure out writing/reading flash via the datasheet for your part (check Chapter 6) as well as the DS30009715 from the PIC24F reference manual. Other option is as vjasinski says. Instead of rolling your own, someone has done the work already. AN1095 should cover what you're looking for (using flash as Emulated EEPROM) |
|
|
|
嗨,我看了AN1095,这对我的应用来说是多余的。我不需要高耐力,我想使用内存作为一个1024字节的块。我对代码空间也非常有限,所以我需要尽可能高效。AN1095解决方案需要大量的代码开销和处理开销。我使用yAtAtditTyx指令来分配空间:无符号int Flash DATA(512)α属性((空间(PSV),对齐(1024),NoOAD,地址(0x1000))),编译器是否有一种方法“预加载”数据i?如果我可以在编译时把一些默认值设置成这个块,那么我也可以假设地址-0x1000是绝对的,这样当我编程TBLPTRS时,我可以把0xMon放入TBLPAG和0x1000到表指针中去吗?在程序内存中有什么地方可以找到这个表(我以前的偏好是在内存的高端)?
以上来自于百度翻译 以下为原文 Hi, I have looked at AN1095 and this is overkill for my application. I do not need high endurance and I want to use the memory as a single block of 1024 bytes. I am also very limited on code space so I need this to be as efficient as possible. There is a lot of code overhead and also processing overhead required for the AN1095 solution. I am using the __attribute__ directive to allocate space: unsigned int flashdata[512] __attribute__ ((space(psv), aligned(1024), noload, address(0x1000))); Is there a way for the compiler to 'preload' data into this- It would be great if I could set some default values into this block at compile time. Can I also assume that the address - 0x1000 is absolute, so that when I program the TBLPTRs I can put 0x0000 into TBLPAG and 0x1000 into the table pointer? Is there any preference where in the program memory to locate this table (My previous preference is at the high end of the memory) |
|
|
|
那么,你想找的HTTP://www. McCHIP.COM/FUMMS/FANDPOST/414053?
以上来自于百度翻译 以下为原文 So something like: http://www.microchip.com/forums/FindPost/414053 That you're looking for? |
|
|
|
|
|
|
|
嗨,即使你不使用AN1095中的“Adress”和“磨损均衡”特性,也有一些源代码可能有用。因为这是存储在闪存中的,当擦除时,内存是0xFFFFF,但是编译器在LIKI中努力将整个数组清除为0x000。可以将数组初始化为任何const数组,您可以尝试:我不知道是否会遇到编译器中的大小限制。当地址属性为对齐值时,不需要对齐(1024)属性,但不应该是问题。PIC24在Flas中具有24位字大小。当存储器用于数组数据存储时,有一些奇怪的特性。因此,当闪存用于图形、图像、字体等时,汇编语言已经用于预加载大面积的内存。迈西尔
以上来自于百度翻译 以下为原文 Hi, Even if you do not use the word-adressing and wear-leveling features of AN1095, there are some pieces of source code in there that might be useful. Since this is stored in flash memory, memory is 0xFFFFFF when erased, but the compiler put in the effort to clear the entire array to 0x0000 when linking the program. You may initialize the array as any const array, you may try: const unsigned int flashdata[512] __attribute__ ((space(psv), noload, address(0x1000))) { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, ..... }; I do not know if you will run into a size limitation in the compiler. aligned(1024) attribute should not be needed when address attribute is aligned value, but shouldn't be a problem either. PIC24 with 24 bit word size in Flash memory have some weird properties when used for array data storage. So when Flash memory is used for graphics, images, fonts and such, assembler language have ben used to preload large areas of memory. Mysil |
|
|
|
我在组装的PIC18F2420上做了这件事。我不知道它是否有助于PIC24:
以上来自于百度翻译 以下为原文 I have done this on a PIC18F2420 in assembly. I don't know if it will help for a PIC24: ;Read a block of data from CODE_ADDR into BUFF_ADDR length BUFF_LEN FlashRead: BSF EECON1, EEPGD ; Point to Program Flash memory BCF EECON1, CFGS ; Access program FLASH or Data EEPROM memory BCF INTCON, GIE ; Disable interrupts MOVFF CODE_ADDR_UPPER, TBLPTRU ; Load TBLPTR with the base MOVFF CODE_ADDR_HIGH, TBLPTRH MOVFF CODE_ADDR_LOW, TBLPTRL MOVFF BUFFER_ADDR_HIGH, FSR0H ; point to flash buffer MOVFF BUFFER_ADDR_LOW, FSR0L MOVFF BUFFER_LEN, COUNTER ;Initialize byte counter READ_BYTE TBLRD*+ ; read into TABLAT and increment MOVF TABLAT, W ; get data MOVWF POSTINC0 DECFSZ COUNTER BRA READ_BYTE EndReadFlash BSF INTCON, GIE ; Enable interrupts RETURN ;Write a block of data from BUFF_ADDR into CODE_ADDR length BUFF_LEN FlashWrite: MOVFF BUFFER_LEN, COUNTER_HI ; number of bytes to write MOVFF BUFFER_ADDR_HIGH, FSR0H ; point to flash buffer MOVFF BUFFER_ADDR_LOW, FSR0L RRNCF COUNTER_HI,F RRNCF COUNTER_HI,F RRNCF COUNTER_HI,F ;Divide by 8 MOVF COUNTER_HI, W ANDLW b'00011111' ;Mask off rotated bits ; MOVLW .16 ; number of write buffer groups of 8 bytes MOVWF COUNTER_HI MOVFF BUFFER_ADDR_HIGH, FSR0H ; point to buffer MOVFF BUFFER_ADDR_LOW, FSR0L PROGRAM_LOOP MOVLW 8 ; number of bytes in holding register MOVWF COUNTER WRITE_WORD_TO_HREGS MOVF POSTINC0, W ; get low byte of buffer data MOVWF TABLAT ; present data to table latch TBLWT+* ; write data, perform a short write ; to internal TBLWT holding register. DECFSZ COUNTER ; loop until buffers are full BRA WRITE_WORD_TO_HREGS PROGRAM_MEMORY BSF EECON1,EEPGD ; point to FLASH program memory BCF EECON1,CFGS ; access FLASH program memory BSF EECON1,WREN ; enable write to memory BCF INTCON,GIE ; disable interrupts MOVLW 55h MOVWF EECON2 ; write 55h MOVLW 0AAh MOVWF EECON2 ; write AAh BSF EECON1,WR ; start program (CPU stall) BSF INTCON,GIE ; re-enable interrupts DECFSZ COUNTER_HI ; loop until done BRA PROGRAM_LOOP BCF EECON1,WREN ; disable write to memory RETURN ERASE_BLOCK MOVFF CODE_ADDR_UPPER, TBLPTRU ; load TBLPTR with base address of memory block MOVFF CODE_ADDR_HIGH, TBLPTRH MOVFF CODE_ADDR_LOW, TBLPTRL BSF EECON1,EEPGD ; point to FLASH program memory BCF EECON1,CFGS ; access FLASH program memory BSF EECON1,WREN ; enable write to memory BSF EECON1,FREE ; enable Row Erase operation BCF INTCON,GIE ; disable interrupts MOVLW 55h MOVWF EECON2 ; write 55h MOVLW 0AAh MOVWF EECON2 ; write AAh BSF EECON1,WR ; start erase (CPU stall) BSF INTCON,GIE ; re-enable interrupts TBLRD*- ; dummy read decrement return Product DB "Ortmaster" CAL CODE 0x2000 ;128 bytes for calibration data CalData: CAL1 CODE 0x2040 ;In blocks of 64 bytes CalData1: |
|
|
|
const无符号int Flash DATA(512)α属性表((空间(PSV),对齐(1024)))地址是可选的。只要你有一个完整的页面,它可以是编译器放置它的地方。但是如果你想要引导加载更新,你需要修复它。而CONST是冗余的空间(PSV)。读访问是通过正常的C,但是这意味着24位字的高8位被浪费了。
以上来自于百度翻译 以下为原文 const unsigned int flashdata[512] __attribute__ ((space(psv), aligned(1024))) The address is optional. As long as you have a full page it can be where the compiler puts it. But you would need it fixed if you intend bootloaded updates. and const is redundant to space(psv). Read access is via normal C, BUT that means the high 8 bits of the 24bit word is wasted. |
|
|
|
只有小组成员才能发言,加入小组>>
5255 浏览 9 评论
2038 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3219 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2268 浏览 5 评论
796浏览 1评论
689浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
618浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
687浏览 0评论
587浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 02:22 , Processed in 1.617315 second(s), Total 98, Slave 82 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号