完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嘿,伙计们,我用的是PIC24FJ1024GA610,我试图写一个值(0x00 2222)到闪存地址0x00 48 FE。在写入地址之前,我读取存储在该位置的值并得到0x00 FFFFFF。这是我创建的用来读取存储值的函数:因为值是0x00 FFFFF,我想我不需要在写之前擦除位置(我可以设置‘1’到‘0’,而不是反过来)。这是我创建的将值写入位置的函数:但是,当我再次读取该位置时,该值仍然为0x00 FFFFFF。我想我搞砸了一些东西…谢谢你的帮助!
以上来自于百度翻译 以下为原文 Hey guys, I am using a PIC24FJ1024GA610, and I am trying to write a value (0x002222) to flash memory address 0x0048FE. Before writing to the address, I read the value stored within the location and got 0x00FFFFFF. This is the function that I created to read the value stored: unsigned long progADDR = 0x0048FE; TBLPAG = ((progADDR & 0x7F0000) >> 16); int addrOffset = (progADDR & 0x00FFFE); readWordL = __builtin_tblrdl(addrOffset); readByteH = __builtin_tblrdh(addrOffset); printf("ReadWordL: %04xrn", readWordL); printf("ReadByteH: %04xrn", readByteH); Since the value is 0x00FFFFFF, I suppose I don't need to erase the location before writing (I can set '1' to '0' but not the other way round). This is the function that I created to write the value to the location: unsigned long progADDR = 0x0048FE; unsigned int writeWordL = 0x2222; unsigned char writeByteH = 0x00; NVMCON = 0x4001; TBLPAG = 0xFA; NVMADRU = progADDR >> 16; NVMADR = progADDR & 0xFFFF;//THIS WAS THE ISSUE: IT WAS && __builtin_tblwtl(0,writeWordL); __builtin_tblwth(0,writeByteH); __builtin_disi(5); __builtin_write_NVM(); However, when I read the location again, the value remained to be 0x00FFFFFF. I think I messed up something here... Thanks a lot for helping! |
|
相关推荐
6个回答
|
|
|
|
|
|
检查以确保你的阅读在写之前工作。我习惯于做ASM,但是C是相似的,你可以使用α-BuixTin…节ABC,CODESOMCONST: pBy'A','B','C'MOV'TBLPEGE(SMONESTST),W0MOV W0,TBLPMOMOV,TBLOBSET(SOMONESTST),W0TBLRDH[W0],TMPTBRRDL[W0],[BUF++];ABMOV.B-TMP,[BUF++];C,我还没有检查过,但它应该是相似的,而且我认为你不能取字节,只有int’s tBLPAG=α-Bug TynIn TBLPGE(ANP;SOMCONSTST);int x=α-BuffTiNIN TBLOPENT(AB;SOMCONSTST),AB,C;C=Y-BuuthTiNIn TBLRDH(X);AB=Y-BuuthTiNTTBLRDL(X);论坛软件写了6个代码语句。
以上来自于百度翻译 以下为原文 Check to make sure your reading is working before writing. I'm used to doing that is asm but C is similar, you can use __builtin. .section abc,code someconst: pbyte 'a','b','c' mov #tblpage(someconst),w0 mov w0,TBLPAG mov #tbloffset(someconst),w0 TBLRDH [w0],tmp TBLRDL [w0],[buf++] ;ab mov.b tmp,[buf++] ;c In C, I haven't checked this but it should be similar and I don't think you can fetch bytes, only int's. TBLPAG = __builtin_tblpage(&someconst); int x=__builtin_tbloffset(&someconst),ab,c; c=__builtin_tblrdh(x); ab=__builtin_tblrdl(x); Forum software wrote 6 code statements. |
|
|
|
哦,天哪,你说得对!我忘了应该是……而不是……谢谢指点!我现在看到了一个变化,但它被更新到0x00 EF23 C6而不是0x2222…我想知道我是不是还在写错误。
以上来自于百度翻译 以下为原文 Oh gosh you are right! I forgot it should be & instead of &&... thanks for pointing out! I did see a change now, but it is updated to 0x00EF23C6 instead of 0x2222... I wonder if I am still writing it wrong. |
|
|
|
也许你的程序占用了这个空间。使用绝对地址不是一个好主意。
以上来自于百度翻译 以下为原文 Maybe your program occupied that space. Not a good idea to use an absolute address. Reserve some space with const. |
|
|
|
哦,是的!对于我的设备,我使用双分区,所以我决定在非活动区域中选择一个位置,并且我能够成功地读写。谢谢大家的帮助!
以上来自于百度翻译 以下为原文 Oh yes it worked!! For my device I am using dual partition, so I decided to choose a location in the inactive region, and I was able to read and write successfully. Thank you all for helping! |
|
|
|
如果你在编译器安装目录中查看LIbPIC30.h(.SuffGrimeh),就会有一些由编译器提供的Flash编写例程。
以上来自于百度翻译 以下为原文 If you take a look libpic30.h in the compiler install directory (..supportgenerich), there are a few Flash write routines already provided by the compiler. |
|
|
|
只有小组成员才能发言,加入小组>>
4840 浏览 9 评论
1842 浏览 8 评论
1757 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2968 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2072 浏览 5 评论
467浏览 1评论
1120浏览 1评论
305浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
373浏览 0评论
268浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-7 07:20 , Processed in 0.939785 second(s), Total 81, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号