完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我正在使用一个PIC24FJ256GA704项目。我正在编程的设备有一对GPIO,最重要的是,一个SPI控制的显示器。我有一个简单的图形库来在框架缓冲器上写文本,然后我定期发送给显示器。我在使用它之前遇到了一些困难,直到我意识到它在调试模式和设备模式(程序)之间显示了明显不同的行为。长话短说,当在调试模式下,一切都如预期的那样工作,而在设备模式下:中断优先级似乎不受尊重:我有一个100-timeEnter中断(在Time3上),它有时不着火,显然是由于从TimeR1(显示刷新)执行的较长的功能,DES。PITE具有较低的优先级。-显示器上的字符是乱七八糟的(随机字符串,而不是应该显示的)。我真的不能把我的头包裹起来的事实是,第二个问题(在显示器上的GABBISH字符串)可以通过添加/删除一定数量的寄存器访问来明显地解决。UPT代码。这是我的Time3中断例程:LeDyRun是一个宏定义为LabbTest.LATB8(一个用于测试目的的小LED)。取决于我在代码中的多少注释行,在程序/设备模式下,下面发生了:0行:一切都如预期的那样工作:1行:屏幕是空的,设备没有响应——2行:字符串是杂乱无章的,设备在使用后变得无响应。它有一段时间(可能在地址错误或类似的情况下结束,不能真正地说出来,因为这个BaviAV不会在调试模式下发生)。- 3行:类似的结果,从我可以看到的,代码大小在某种程度上干扰了字体,这些字体被定义为conchar数组。但是,这在调试模式中不发生,而且两者都是。MAP文件看起来很好(调试和生产。MAP文件具有相同的地址。const部分)。我意识到问题是模糊地描述的,但我不知道该怎么办。我的问题是:1。有人以前遇到过类似的问题吗?2。你认为哪些信息能更好地理解我的问题和/或解决问题?如果它可以有任何帮助,那就是我的配置位。我运行在16MHz(FoSC)的内部FRC+PLL。
以上来自于百度翻译 以下为原文 Hello everyone, I'm working on a project using a PIC24FJ256GA704. The device I'm programming has a couple of GPIO and, most importantly, an SPI-controlled display. I have a simple graphic library to write text on a framebuffer that I then periodically send to the display. I was having some difficulties working with it until I realized it was displaying a significantly different behaviour between Debug mode and Device mode (Program). Long story short, when in Debug mode everything works as expected, while in Device mode: - Interrupt priority is seemingly not respected: I have a 100us timer interrupt (on timer3) that sometimes doesn't fire, apparently due to a longer function being executed from timer1 (the display refresh), despite the latter having a lower priority. - The characters on the display are gibberish (random strings instead of what should be displayed). What I really can't wrap my head around is the fact that the second problem (gibberish strings on display) can be resolved apparently by adding/removing a certain number of register accesses in interrupt code. This is my timer3 interrupt routine: /*----------------------------------------------------------------------------*/ /* Timer Interrupt 3 - 100 usec */ /*----------------------------------------------------------------------------*/ void __attribute__((interrupt, auto_psv)) _T3Interrupt (void) { static int triac_on_time = 0; if (f_pwm_on) { if (pwm_off_time > 0) { TRIAC = 0; pwm_off_time--; if (pwm_off_time == 0) { triac_on_time = 3; TRIAC = 1; IEC0bits.T1IE = 0; IEC0bits.T2IE = 0; } // LED_RUN = LED_RUN; // LED_RUN = LED_RUN; // LED_RUN = LED_RUN; } else if (triac_on_time > 0) { triac_on_time--; if (triac_on_time == 0) { TRIAC = 0; IEC0bits.T1IE = 1; IEC0bits.T2IE = 1; } } } else { TRIAC = 0; IEC0bits.T1IE = 1; IEC0bits.T2IE = 1; } IFS0bits.T3IF = 0; } LED_RUN is a macro defined as LATBbits.LATB8 (a small LED used for testing purposes). Depending on how many of the commented out lines I leave in the code, in Program/Device mode, the following happens: - 0 lines: everything works as expected - 1 line: the screen is empty and the device unresponsive - 2 lines: the strings are gibberish and the device becomes unresponsive after using it for a while (possibly ending up in an address error or similar, can't really tell because this beaviour does not occur in Debug mode). - 3 lines: similar results, ... From what I can see it appears the code size is somehow messing with the fonts, that are defined as const char arrays. However, again, this does not occur in Debug mode, and both .map files seem fine (Debug and Production .map file have the same addresses for .const sections). I realize the problem is vaguely described, but I don't know what to do at this point. My questions are: 1. Did anyone stumble in a similar problem before? 2. What information do you think would be useful to better understand my problem and/or fix it? If it can be of any help, those are my configuration bits. I'm running at 16MHz (FOSC) with the internal FRC+PLL. /* FSEC */ #pragma config BWRP = OFF /* Boot Segment Write-Protect bit (Boot Segment may be written) */ #pragma config BSS = DISABLED /* Boot Segment Code-Protect Level bits (No Protection (other than BWRP)) */ #pragma config BSEN = OFF /* Boot Segment Control bit (No Boot Segment) */ #pragma config GWRP = OFF /* General Segment Write-Protect bit (General Segment may be written) */ #pragma config GSS = DISABLED /* General Segment Code-Protect Level bits (No Protection (other than GWRP)) */ #pragma config CWRP = OFF /* Configuration Segment Write-Protect bit (Configuration Segment may be written) */ #pragma config CSS = DISABLED /* Configuration Segment Code-Protect Level bits (No Protection (other than CWRP)) */ #pragma config AIVTDIS = OFF /* Alternate Interrupt Vector Table bit (Disabled AIVT) */ /* FBSLIM */ #pragma config BSLIM = 0x1FFF /* Boot Segment Flash Page Address Limit bits (Boot Segment Flash page address limit) */ /* FSIGN */ /* FOSCSEL */ #pragma config FNOSC = FRCPLL//OSCFDIV /* Oscillator Source Selection (Internal Fast RC (FRC)) */ #pragma config PLLMODE = 0b0001//DISABLED /* PLL Mode Selection (No PLL used; PLLEN bit is not available) */ #pragma config IESO = OFF /* Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source) */ /* FOSC */ #pragma config POSCMD = NONE /* Primary Oscillator Mode Select bits (XT Crystal Oscillator Mode) */ #pragma config OSCIOFCN = ON /* OSC2 Pin Function bit (OSC2 is a General Purpose IO) */ #pragma config SOSCSEL = OFF /* Digital mode */ #pragma config PLLSS = PLL_FRC /* PLL Secondary Selection Configuration bit (PLL is fed by the on-chip Fast RC (FRC) oscillator) */ #pragma config IOL1WAY = OFF /* Peripheral pin select configuration bit (Allow multiple reconfigurations) */ #pragma config FCKSM = CSECMD /* Clock Switching Mode bits (Clock switching is enabled,Fail-safe Clock Monitor is disabled) */ /* FWDT */ #pragma config WDTPS = PS32768 /* Watchdog Timer Postscaler bits (1:32,768) */ #pragma config FWPSA = PR128 /* Watchdog Timer Prescaler bit (1:128) */ #pragma config FWDTEN = OFF /* Watchdog Timer Enable bits (WDT and SWDTEN disabled) */ #pragma config WINDIS = OFF /* Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode) */ #pragma config WDTWIN = WIN25 /* Watchdog Timer Window Select bits (WDT Window is 25% of WDT period) */ #pragma config WDTCMX = WDTCLK /* WDT MUX Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits) */ #pragma config WDTCLK = LPRC /* WDT Clock Source Select bits (WDT uses LPRC) */ /* FPOR */ #pragma config BOREN = ON /* Brown Out Enable bit (Brown Out Enable Bit) */ #pragma config LPCFG = OFF /* Low power regulator control (No Retention Sleep) */ #pragma config DNVPEN = ENABLE /* Downside Voltage Protection Enable bit (Downside protection enabled using ZPBOR when BOR is inactive) */ /* FICD */ #pragma config ICS = PGD2 /* ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1) */ #pragma config JTAGEN = OFF /* JTAG Enable bit (JTAG is disabled) */ /* FDEVOPT1 */ #pragma config ALTCMPI = DISABLE /* Alternate Comparator Input Enable bit (C1INC, C2INC, and C3INC are on their standard pin locations) */ #pragma config TMPRPIN = OFF /* Tamper Pin Enable bit (TMPRN pin function is disabled) */ #pragma config SOSCHP = ON /* SOSC High Power Enable bit (valid only when SOSCSEL = 1 (Enable SOSC high power mode (default)) */ #pragma config ALTI2C1 = ALTI2CDIS /* Alternate I2C pin Location (SDA1 and SCL1 on RB9 and RB8) */ |
|
相关推荐
10个回答
|
|
构建、调试和生产都有相同的优化水平吗?代码中的任何操作PSVPAG寄存器?任何使用π属性或语法的定义?自定义链接器脚本?基于μ调试的条件编译?任何人需要的是一个简单的项目来证明这个问题。
以上来自于百度翻译 以下为原文 Do both builds, debug vs. production, have the same level of optimization? Anything in your code that manipulates the PSVPAG register? Any definitions that use __attribute__ or #pragma? Custom linker script? Conditional compilation based upon __DEBUG? What anyone needs is a simple project that demonstrates this issue. |
|
|
|
甚至有可能有不同的选择吗?我只使用一个配置,优化级别不是直接的。我在PSV部分中保存了一些字符串,但是在寻找一个解决方案时,我把它们定义为const。我的中断有π属性((中断,AutoYPSV)),并且一些代码操作了最后在显示器上加扰的字符串,因此可能值得尝试移动它。其他地方,看看有什么变化。没什么。是的,我明白。用一个简单的例子来确定问题并复制它是不容易的,我会继续尝试。即使在一个模糊的描述之后,你的问题也已经很有帮助了。
以上来自于百度翻译 以下为原文 Is it even possible to have different options? I only use a single configuration, and the optimization level is 0 Not directly. I had some strings stored esplicitly in the PSV section, but I redefined them as const while looking for a solution. My interrupts have __attribute__((interrupt, auto_psv)), and some of that code manipulates the strings that end up scrambled on the display, so it might be worth trying to move it somewhere else and see what changes. Nothing of the sort. Yes, I understand. It's just not easy to pinpoint the problem and reproduce it with a simple example; I'll keep trying. Even after a vague description, your questions are already helpful. |
|
|
|
嗨,调试和释放模式是相似的,除了非常少的点:*在调试模式下,看门狗会自动禁用以及代码保护。*该工具通常在MCLR上增加一个内部的上拉(如果您断开您的板,它可能表现出不同的行为取决于您的外部复位CIR。CuTyRy:可能发生的是,两个GPIOS在调试MODESO中被初始化,如果您的软件在发布模式下不运行或运行异常,您最可能错过了一些初始化(NB:我假定您没有将任何外部信号附加到您的硬件上的PGC/PGD引脚)任何未使用的输入P在必须被初始化为输出或极化外,否则你会得到噪音到PIC,可能会出现任何奇怪的行为问候。
以上来自于百度翻译 以下为原文 Hi, Debug and release mode are similar except very few points : * In debug mode , watchdog is automatically disables as well as code protection. * The tool generally add an interna pull-up on MCLR (if you disconnect your board it may exhibit a different behaviour depending upon your external reset circuitry * it may happen that a couple of GPIOs are initialized in debug mode So if your software does not run or run strangely in release mode you have most probably missed some initialization ( NB : i suppoed you did not attach any external signals to PGC / PGD pins on your hardware) Any unused input pin MUST either be initialized as output or polarised externally otherwise you'll get noise into the PIC which may exhibit any strange behaviour Regards |
|
|
|
在Time1中断中刷新显示,还是在主循环中设置标志和刷新?如果前者,尝试后者。
以上来自于百度翻译 以下为原文 Are you refreshing the display within timer1 interrupt or just setting a flag and refreshing in the main loop? If the former, try the latter. |
|
|
|
在RISC中提到的不同之处在于:在调试模式中,一个小的“调试内核”被加载到与IDE中的调试器通信的代码中,调试内核使用PGCX/PGDX对与调试器通信,因此您不能在代码中使用它们。调试内核还初始化了“模拟/数字”模式,用于具有“数字”的模拟功能的PIN,当它们初始化为“模拟”时,当进行重置时,调试内核控制并等待与调试器的一些交互,而您的代码在“R”中重置。ELASE的模式-如果你使用监视窗口或者以其他方式查看各种外围寄存器,你会得到误导的结果(尤其是提供FIFO结果的寄存器)。底线是你真的应该初始化你使用的所有东西。苏珊
以上来自于百度翻译 以下为原文 As well as the differences that RISC mentions, others are: - in debug mode, a small 'debug kernel' is loaded in with your code that communicates with the debugger in the IDE - that debug kernel uses the PGCx/PGDx pair to communicate with the debugger so you cannot use them for anything in your code - the debug kernel also initialises the 'analog/digital' mode for pins that have an analog function to 'digital' where as they otherwise initialise to 'analog' - when you do a reset, the debug kernel takes control and waits for some interaction with the debugger, whereas you code starts on reset in 'release' mode - if you use the watch window or otherwise to look at various peripheral registers, you can get misleading results (especially any register that provides the results of a FIFO) The bottom line is that you really should initialise everything that you use. Susan |
|
|
|
你猜对了。同样,所有未使用的引脚都被初始化为输出,并被驱动到0。两个都试过了,显然没有区别(虽然我应该适当地检查,如果Time3在两种情况下确实跳过,在接下来的几天内都会发生)。我想我已经看过了,但是我会仔细检查。在接下来的日子里,我们将尝试一个不同的(虽然非常相似)PIC的程序和设备,因为我们真的需要完成这项工作。如果运气好的话,我会不断尝试去理解我空闲时间里的问题,否则我需要用一个可重复的例子来确定问题。
以上来自于百度翻译 以下为原文 You suppose right. Also all the unused pins are initialized as output and driven to 0. Tried both, apparently no difference (though I should check properly if the timer3 really skips sometimes in both cases, will do in the next days). I think I have, but I'll double check. In the next days we will try the same program & device with a different (albeit very similar) PIC, because we really need to get this job done. If by luck it works I'll keep trying to understand what the problem was in my spare time, otherwise I'll need to pinpoint the problem with a reproducible example. |
|
|
|
我们尝试使用PIC24EP256GP204代替PIC24FJ256GA704;它有一个非常类似的引脚和规格,我们已经成功地完成了它。长话短说,调试和生产模式之间的差异完全消失了。电路和程序是相同的(对于一些不同名称的寄存器来说是保存的)。我们仍然有一些中断定时器的问题,但我认为这是一个单独的问题。也许有一天,我会回到原来的图片,并试图组装一个可重复的例子,但现在我们有更紧迫的事情要照顾。感谢所有试图帮助的建议。
以上来自于百度翻译 以下为原文 Update So we tried using a PIC24EP256GP204 instead of the PIC24FJ256GA704; it has a very similar pinout and specs, and we already worked succesfully with it. Long story short the difference between Debug and Production mode simply disappeared. The circuit and program are the same (save for some registers that have different names). We still have some problems with interrupt timers, but I believe that to be a separate issue. Maybe one day I'll come back to the original PIC and try to assemble a reproducible example, but for now we have more pressing matters to attend to. Thanks to everyone who tried to help with suggestions. |
|
|
|
嗨,还有几点要考虑……你有没有启用中断优先级?我注意到你在T1中操作中断其他的中断启用/禁用位但是我们不知道它们的优先级是什么。这是否有可能产生一个问题:操作其他中断在中断中启用/禁用位常常是问题的根源。确保T1具有更高的优先级,或者在主例程中执行它。另一种方式是使用相同优先级的所有中断。
以上来自于百度翻译 以下为原文 Hi, A few more points to think about... Did you (or not) enable interrupt priority ? I noticed you manipulate in T1 interrupt other interrupts enable/disable bits but we don't know what is their priority. Also the succession of enable/disable T2 and T3 is not atomic. Could this potentially generate an issue My point is : manipulating other interrupts enable/disable bits from within an interrupt is often a source of issues... Make sure that either T1 has a higher priority or do it in the main routine. another way is having all interrupts with the same priority Regards |
|
|
|
我启用了它并尝试了几种不同的组合。然而,我不想在这里讨论这个问题,因为我认为这是一个单独的问题,值得另一个线程(我很快会创造)。调试和生产模式之间的差异甚至在禁用所有中断之后仍然存在。
以上来自于百度翻译 以下为原文 I enabled it and tried several different combinations. However I don't really want to discuss this here because I believe it to be a separate issue, deserving another thread (that I will most likely create soon). The differences between Debug and Production mode persist even after disabling all interrupts. |
|
|
|
我似乎找到了解决办法。我一直有几个难以解释的问题,直到我注意到内存模型的GCC设置都被设置为[默认](Project Projices -Gt;XC16GCC & Gt;内存模型)。所有不必要的行为(变量不改变它们的值、地址错误、……)都在发布MOD中发生。当我将内存模型设置为“大”的时候,在数据、标量和代码中都不存在调试。我认为编译器(链接器)如果我的代码增长过多,需要大的模型运行,就应该抛出一个错误。我没有时间找到问题和/或解决方案的更精确的描述。
以上来自于百度翻译 以下为原文 I seem to have found a workaround. I kept having several unexplicable problems until I noticed the gcc settings for the memory model were all set to [default] (Project properties -> xc16-gcc -> Memory model). All the unwanted behaviours (varibles not changing their values, address errors, ...) that were happening in Release mode but not in Debug disappeared when I set the memory model to "large" for data, scalar and code. I thought the compiler (the linker) was supposed to throw an error if my code grew too much and required large models to run. I don't have the time to find a more precise description of the problem and/or the solution. |
|
|
|
只有小组成员才能发言,加入小组>>
5189 浏览 9 评论
2009 浏览 8 评论
1933 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3181 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2232 浏览 5 评论
746浏览 1评论
632浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
517浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 03:44 , Processed in 1.801502 second(s), Total 94, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号