完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一段代码,通过扫描PSoC4程序空间来连续地计算程序CRC。初始CRC是在第一POR上计算的。然后将16位CRC存储在闪存空间的最后一行的最后2字节中,并用于比较。所以,我从0x0扫描到0x00 000 8000 siZeof(CRC)。如果程序存储器在操作期间发生变化(即运行的CRC与程序CRC不匹配),则指令程序产生故障代码并停止正常操作。
我一直在广泛地测试我的项目。一切都很好。当我有意破坏Flash中的随机位置时,通常在验证和验证测试期间进行,CRC检查会像预期的那样捕获故障。 这是我希望有人能回答的问题。在系统中,我有一个I2C外围设备,这取决于连接到一组共享引脚的设备。在测试期间,我通过调用I2C*Sistar()启用I2C SCB。通过调用I2CyStutter()来禁用它。在调用I2CYSTART()的瞬间(而无其他),CRC校验过程注册程序存储器中的一个变化并引发错误。我对此感到惊讶,因为寄存器的处理器和SCB块利用在我的扫描区域之外(分别为0x40000—0x400 0FFF和0x400 6000 - -0x400 6FFFF)。 我只能得出结论,闪光的东西正在发生变化,但在TRM中很少能发现这可能是什么。在I2CXSTART()期间,中断是否启用,这种行为是相同的。 有没有人知道Flash在改变什么,在哪里改变,或者从I2C开始的其他副作用可能是什么让程序认为有些东西正在改变? 谢谢。 以上来自于百度翻译 以下为原文 I have a piece of code that is continuously calculating a program CRC by scanning the PSoC4 program space. The initial CRC is calculated on the first POR. A 16-bit CRC is then stored in the last 2-bytes of the last row of the FLASH space and referenced for comparison. So, I scan from 0x0 to 0x00008000-sizeof(CRC). If the program memory ever changes during operation (i.e. the running CRC does not match the program CRC) the program is instructed to produce a fault code and discontinue normal operation. I have been testing my project extensively. Everything works great. When I intentionally corrupt a random location in flash, as is typically done during verification and validation testing, the CRC checking catches the fault as expected. Now here's the gotcha I'm hoping someone has an answer to. I have an I2C peripheral in the system, which is optionally enabled depending upon the device connected to a group of shared pins. During testing, I enable the I2C SCB by calling I2C_Start(). It is similarly disabled by calling I2C_Stop(). Within moments of calling I2C_Start() (and nothing else), the CRC checking process registers a change in the program memory and throws an error. I am surprised by this because the registers the processor and SCB blocks utilize are outside of my scanning area (0x40000000 – 0x4000FFFF and 0x40060000- -0x4006FFFF respectively). I can only conclude that something in flash is changing but can find very little in the TRM to suggest what that might be. This behavior is the same whether interrupts are enabled or not during I2C_Start(). Does anyone know what in Flash is changing, where it is changing, or what other side effect starting I2C might have that ismaking the program think something is changing? Thanks. |
|
相关推荐
14个回答
|
|
默认的编程过程将清除所有Flash内容。也就是说,所有的Flash都写到0x00。你可以另外指定,但是我选择这样离开。CRCITIIT检查CRC位置。如果是0x000,系统CRC必须第一次计算和写入。
以上来自于百度翻译 以下为原文 The programming process by default will clear all flash contents. That is, all flash is written to 0x00. You can specify otherwise, but I choose to leave it that way. CRC_Init checks the CRC location. If it is 0x0000, the system CRC must be calculated and written for the first time. |
|
|
|
1。如果你不启动/启用I2C,CRC检查是正确的吗?2。你能设置它使I2C由输入引脚启用/禁用。IE高,使I2C和低禁用CRC运行程序的PIN高和低,看看是否仍然失败。三。如果它只是失败的每一次针是高。如果可能,设置和清除另一个输出引脚,当你调用写到Flash函数调用时。使用CRO查看是否有人在呼叫。
以上来自于百度翻译 以下为原文 1. If you don't start/enable the I2C, the CRC check is correct? 2. Can you set it up so that the i2C is enable/disable by an input pin. ie high to enable i2C and low to disable CRC run the program with pin high and low and see if that still fail. 3. If it only fail every time the pin is high. If it is possible, set and clear another output pin when ever you call the write to flash function call. Use a CRO to see if it was being called. |
|
|
|
|
|
|
|
以下是一些有趣的线索。我试着让CRC检查过程原子化。那没有解决任何问题。CRC仍然失败。CRC校验背后的最初想法是,如果程序CRC失败一次,它将永远失败。所以这次,如果CRC在后续运行中通过,我只允许将该标志重新设置为OK。这起作用了……但这只是解决问题的一个帮手。它确实给出了问题所在的线索。
所以还有其他的可能性。运行的CRC值可能会变得腐败,尽管它是一个在函数内声明的静态变量,并且在理论上是不可访问的。错误标志可能会损坏,但这也是静态变量。或者堆栈可能变得腐败。 证据似乎标志着国旗腐化了。但是,除了调用API函数之外,我并没有以任何方式处理堆栈。因此,某种东西可能会以某种方式成长。我试着在CYDWR增加堆栈,但也没用。 我的下一步是看装配,看看物体在哪里。尽管如此,我还是得跟你谈谈。 在任何情况下,只有在调用I2CYSTART()时才会出现问题。 以上来自于百度翻译 以下为原文 Here are a few more interesting clues. I tried making the CRC checking process atomic. That didn't fix anything. CRC still fails. The original idea behind the CRC check is that if the program CRC fails even once, it is forever failed. So this time I just allow that flag to be re-set to OK if the CRC passes in a subsequent run. That worked...but is only a bandaid to the problem. It does give some clues about where the problem lies. So there are a couple other possibilities. The running CRC value could become corrupt, though it is a static variable declared within a function and inaccessable (in theory) to the outside world. The error flag could become corrupt, but that is also a static variable. Or the stack could become corrupt. The evidence seems to point to the flag becoming corrupted. But I am not manipulating the stack in any way besides calling API functions. So something may be growing into it somehow. I tried growing the stack in CYDWR, but that didn't help either. My next step is to look into the assembly and see where things are located. I will have to get back to you on that though. In any case, the problem only occurs when I2C_Start() is called. |
|
|
|
你指出的证据似乎表明ISR相关。
如果在CRC计算中使用下一个字节访问的指针,则 需要声明哪些波动以确保ISR的免疫性 相关腐败。 问候,Dana。 以上来自于百度翻译 以下为原文 Evidence as you point out sure seems to indicate ISR related. If you use a pointer for next byte access in CRC computation, thats what needs to be declared volatile to insure immunity from ISR related corruption. Regards, Dana. |
|
|
|
如果可以,I2CL启动例程使用相同的CRC生成器硬件吗?
以上来自于百度翻译 以下为原文 If may, Does I2C_Start routine using same CRC generator hardware? |
|
|
|
1。你提到你让CRC检查原子,我假设你在CRC检查过程中有所有中断被禁止。
2、如果你只是启动,但在启动时禁用I2C一次,看看这有什么区别吗? 以上来自于百度翻译 以下为原文 1. You mentioned that you make the CRC check atomic, I assume you have all interrupt disabled during the CRC check process. 2. If you just start but disable the i2C at start up only once, see if that makes any difference? |
|
|
|
我感激所有的想法。我会试着回答一些问题。
1。如果你不启动/启用I2C,CRC检查是正确的吗?2。你能设置它使I2C由输入引脚启用/禁用。IE高,使I2C和低禁用CRC运行程序的PIN高和低,看看是否仍然失败。三。如果它只是失败的每一次针是高。如果可能,设置和清除另一个输出引脚,当你调用写到Flash函数调用时。使用CRO查看是否有人在呼叫。 1。如果我不启动I2C外围设备,CRC校验总是有效的。我没有看到它失败,除非我故意破坏程序空间的验证和验证的目的。 2。我不能再使用别针了。芯片是在一个系统中,我不容易获得引脚。我可以把命令发送到芯片,以启用和禁用I2C在飞行中,这是我看到的问题。 三。在这个过程中,我不写Flash。我只看闪光灯。16位程序CRC在芯片的寿命期间只写一次。在芯片的第一次上电过程中,计算完整的系统CRC。这个值存储在程序Flash的末尾,不再写入。假设这个值表示一个有效的程序。运行时CRC计算简单地将计算结果与存储在Flash中的结果进行比较。 奇怪的是,在第一个CRC生成/存储周期之后,W/O启动I2C,您会通过另一个CRC校验吗?思想是你的扫描PTR是一个字节关闭(或类似的东西)和拾取闪存的变化,因为CRC写入最后2行闪存。如果在ISR中使用,则指针将被声明为易失性。 对。完整的程序CRC大约每2秒重复计算一次。在不启动I2C的情况下,它们总是正确的。CRC函数不在ISR中。它在空闲周期从主呼叫。我的程序是一个非阻塞超级循环。 简化的超级循环执行看起来是这样的: (1){ 如果定期出现事件断言{ 照料它 } 现在/在空闲时间 { 运行增量CRC校验 } } 我尝试停止中断,而“运行增量CRC检查”代码通过使用“CyGalAcActuabess”和“CyGalAlultDelabelabelabelabl”命令来执行。那无济于事。 你指出的证据似乎表明ISR相关。如果在CRC计算中使用下一个字节访问的指针,则需要声明其易失性,以确保ISR相关的抗腐败能力。 我已经尝试将CRC变量声明为易失性(再次,这些不在ISR中)。这无济于事。 如果可以,I2CL启动例程使用相同的CRC生成器硬件吗? 我的CRC功能是软件,与I2C功能无关。 1。你提到你让CRC检查原子,我假设你在CRC检查过程中有所有中断被禁止。2。如果你只是启动,但在启动时禁用I2C,只看一次,看看这有什么区别吗? 1。是的,正如上面提到的,在CRC计算过程中,我曾尝试中断中断。但是,假定程序是如何编写的,假定ISRS执行并正确返回,这是不必要的。结果相同,CRC失败。 2。你建议如何取消I2C?当然没有I2CyDISABLE()函数。 以上来自于百度翻译 以下为原文 I appreciate all the thoughts. I will try answering some questions. 1. If you don't start/enable the I2C, the CRC check is correct? 2. Can you set it up so that the i2C is enable/disable by an input pin. ie high to enable i2C and low to disable CRC run the program with pin high and low and see if that still fail. 3. If it only fail every time the pin is high. If it is possible, set and clear another output pin when ever you call the write to flash function call. Use a CRO to see if it was being called. 1. If I don't start the I2C peripheral, CRC checking always works. I've neve seen it fail unless I intentionally corrupt the program space for purposes of verification and validation. 2. I am unable to use another pin. The chip is in a system and I don't have easy access to pins. I can send commands to the chip to enable and disable I2C on the fly, which is where I see the problem. 3. I'm not writing flash during this process. I only read the flash. The 16-bit program CRC is written only once during the life of the chip. During the very first power up of the chip, a complete system CRC is calculated. This value is stored at the end of the program flash and never written again. It is assumed that this value represents a valid program. Runtime CRC calculations simply compare a calculated result with that stored in flash. Curious, after the first CRC generate/store cycle, w/o starting I2C, you do another CRC check that passes ? Thought is your scan ptr is one byte off (or something like this) and picking up the change in flash due to CRC write into last 2 rows of flash. The pointer of course would be declared volatile if used in an ISR. Yes. Complete program CRCs are calculated repeatedly approximately every 2 seconds. They are always correct without starting I2C. The CRC function is not in an ISR. It is called from main during idle cycles. My program is a non-blocking super-loop. Simplified super loop execution looks like this: while(1) { if regularly occuring event asserts { take care of it } else // now in idle time { run incremental crc check } } I have tried halting interrupts while the "run incremental crc check" code executes by using "CyGlobalIntEnable" and "CyGlobalIntDisable" commands around it. That doesn't help. Evidence as you point out sure seems to indicate ISR related. If you use a pointer for next byte access in CRC computation, thats what needs to be declared volatile to insure immunity from ISR related corruption. I have tried declaring the CRC variables as volatile (again, these are not within an ISR). It doesn't help. If may, Does I2C_Start routine using same CRC generator hardware? My CRC function is sofware and unrelated to I2C functionality. 1. You mentioned that you make the CRC check atomic, I assume you have all interrupt disabled during the CRC check process. 2. If you just start but disable the i2C at start up only once, see if that makes any difference? 1. Yes, as mentioned above, I have tried disabling interrupts during CRC computation. This, however, is unnecessary given how the program is written, assuming ISRs execute and return properly. The result was the same; CRC failed. 2. How would you propose disableing the I2C? There is of course no I2C_Disable() function. |
|
|
|
你可以考虑提交一个案子。
CyPress网站 “支持” “技术支持” “创造一个案例” 这应该照顾禁用。 以上来自于百度翻译 以下为原文 You might consider posting a case at - www.cypress.com “Support” “Technical Support” “Create a Case” This should take care of disable - |
|
|
|
你能发布计算CRC的代码吗?
如果有一个想法我需要验证: 根据PSOC4 TRM,可执行内存从0亿×0到0×1FFFFFF,在0x00亿到0x00,7FFF是闪存,但是一个“异常向量表”位于0x00亿,它也被用作中断表(见TRMPAGE 38),所以可能是启动I2C COM。PoNoT只是设置了一个新的中断向量,因此改变了这个位置,这样您就可以通过排除该区域来测试。或者通过检查异常处理程序26或27是否发生更改,这些是SCB块中的异常处理程序。如果您是有利的,您可以将I2CYSTART()函数的调用序列向下追溯到它真正执行的过程,可能向下到汇编程序级别。 以上来自于百度翻译 以下为原文 Can you post the code for calculating the CRC? If have an idea I would need to verify:
|
|
|
|
这就是我如何停止I2C,这不是问题。
关于向量表,我检查了两个位置,并且找不到那些内存位置的任何更改。 以上来自于百度翻译 以下为原文 That is exactly how I stop I2C. That's not the problem. With regard to the vector table, I checked both locations and could not find any changes to those memory locations. |
|
|
|
你好,达纳奈特和HLI,
我想我误解了你的意见。我试了你的建议。我执行以下操作 I2CYSTART();I2CyStUTE();CRCYIN();/初始化程序CRC; 你猜怎么着?它起作用了。之后,我可以启动和停止I2C外围设备,并且系统计算CRC保持正确。 如果你交换它们: CRCI In();//初始化程序CRC,如果它不是I2CYSTART();I2CYSTATE(); 它失败了。你们两个都在做某事。不过我还不确定。根据HLI的建议,也许创建了一个新的中断向量。在内存监视调试会话期间,我看不到它。我试过跳过程序内存的最初几个字节,但是还没有成功。 以上来自于百度翻译 以下为原文 Hi danaaknight and hli, I think I missunderstood your comments. I tried what you suggested. I executed the following I2C_Start(); I2C_Stop(); CRC_Init(); // initialize program CRC if it hasn't been And guess what? It works. I can start and stop the I2C peripheral after that and the system calculation CRC remains correct. If you swap them: CRC_Init(); // initialize program CRC if it hasn't been I2C_Start(); I2C_Stop(); it fails. So, you both are on to something. I'm not sure what yet though. Perhaps a new interrupt vector was created, as suggested by hli. I'm just not seeing it during the debugging session with memory watch. I've tried skipping the first few bytes of program memory, but haven't had success yet. |
|
|
|
函数“CRCGIN()”是否执行CRC运算并在第一次调用时将值写入闪存?
如果是,你如何确定它是否是第一次?将用于检查损坏的标志/字节,因此它没有写入CRC,下次当CRC值未写入时,它会失败。 以上来自于百度翻译 以下为原文 Is the function "[size=11.199999809265137px]CRC_Init()" perform the CRC calcution and write the value to the flash if it is the first time being called? if it is, how do you determine if it is the first time or not? Would that flag/byte used for checking corrupted so it didn't write the CRC and the next time it failed as the CRC value was not written |
|
|
|
我需要一个编辑函数。
压杆过快 如果你第一次被调用,你有一个功能来完成CRC运算并把这个值写在Flash上吗? 如果是,你如何确定它是否是第一次?将用于检查损坏的标志/字节,因此它没有写入CRC,下次当CRC值未写入时,它会失败。 以上来自于百度翻译 以下为原文 [size=11.199999809265137px]I need an edit function. [size=11.199999809265137px] [size=11.199999809265137px]Press post too quickly [size=11.199999809265137px] [size=11.199999809265137px]You have a function to perforn the CRC calcution and write the value to the flash if it is the first time being called? [size=11.199999809265137px]if it is, how do you determine if it is the first time or not? Would that flag/byte used for checking corrupted so it didn't write the CRC and the next time it failed as the CRC value was not written |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2075 浏览 1 评论
1829 浏览 1 评论
3645 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1766 浏览 6 评论
1517 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
516浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
370浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
413浏览 2评论
360浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
868浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 13:12 , Processed in 1.392519 second(s), Total 102, Slave 85 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号