完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我现在正在使用TCP IP堆栈V5.42.08,在调试项目时,我发现程序被困在助手循环中。精确地考虑变量VBIT计数,在0初始化,并将它与0值进行比较。这是我不理解的:为什么我们要增加VBIT?在做IF条件之前(++是变量之前,很明显),如果我们希望这个变量保持在0。我是否错过了一些函数,将它放在-- 1之前?这里是帮助文件函数,其中出现问题。
以上来自于百度翻译 以下为原文 Hi, I'm currently working with the TCP IP Stack v5.42.08 and while debugging the project I found that the program was stuck in Helpers loop. Precisely regarding the variable vBitCount, initialized at 0, and compared at the end to 0 value. This is what I don't understand : why do we increment vBitCount BEFORE doing the if condition (++ are before the variable, obviously ), if we want that variable to stay at 0. Did I miss some function that puts it at -1 right before ? Here is the Helpers file function where the problem occurs. DWORD GenerateRandomDWORD(void) { BYTE vBitCount; WORD w, wTime, wLastValue; DWORD dwTotalTime; union { DWORD dw; WORD w[2]; } randomResult; #if defined __18CXX { //same loop than below but for 18cxx devices } #else { WORD AD1CON1Save, AD1CON2Save, AD1CON3Save; WORD T1CONSave, PR1Save; // Save hardware SFRs AD1CON1Save = AD1CON1; AD1CON2Save = AD1CON2; AD1CON3Save = AD1CON3; T1CONSave = T1CON; PR1Save = PR1; // Set up Timer and A/D converter module AD1CON1 = 0x0000; // Turn off the ADC so we can write to it AD1CON3 = 0x9F00; // Frc A/D clock, 31 Tad acquisition AD1CON2 = 0x003F; // Interrupt after every 16th sample/convert AD1CON1 = 0x80E4; // Turn on the A/D module, auto-convert T1CON = 0x8000; // TON = 1, no prescalar PR1 = 0xFFFF; // Don't clear timer early vBitCount = 0; /* ---- variable used at the end of the loop to check entropy of packets----- */ dwTotalTime = 0; wLastValue = 0; randomResult.dw = LFSRRand(); while(1) { ClrWdt(); #if defined(__C30__) while(!IFS0bits.AD1IF); // A/D interrupt flag bit #else while(!IEC0bits.AD1IE) // A/D interrupt enable { //enable interrupt ad1 IEC0bits.AD1IE=1; } #endif wTime = TMR1; TMR1 = 0x0000; #if defined(__C30__) IFS0bits.AD1IF = 0; #else IFS1CLR = _IFS0_AD1IF_MASK; #endif w = LFSRRand(); // Wait no longer than 1 second obtaining entropy dwTotalTime += wTime; if(dwTotalTime >= GetInstructionClock()) { randomResult.w[0] ^= LFSRRand(); randomResult.w[1] ^= LFSRRand(); break; } // Keep sampling if minimal entropy was likely obtained this round if(wLastValue == wTime) continue; // Add this entropy into the pseudo random number generator by reseeding LFSRSeedRand(w + (wLastValue - wTime)); wLastValue = wTime; // Accumulate at least 32 bits of randomness over time randomResult.dw <<= 1; if(LFSRRand() & 0x0080) randomResult.w[0] |= 0x1; // See if we've collected a fair amount of entropy and can quit early if(++vBitCount == 0u) break; } Attached Image(s) |
|
相关推荐
1个回答
|
|
|
好吧,我忘了考虑变量类型。在一个一步一步的模式下,循环在255点后被踩出。在正常模式下,我在1分钟左右的时间里没有等待我之前的尝试。程序在我的断点上停止了。我的坏。谢谢你的帮助。
以上来自于百度翻译 以下为原文 Ok i did forgot to think about the variable type. the loop is stepped out after 255 in step by step mode. In normal mode I didn't waited enough on my previous attempts cause after 1 minute or so the program halted on my breakpoint. My bad. Thanks for the assist. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 06:19 , Processed in 0.526914 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1586