完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我有一个问题,我的LIS的PIC不是SPI初始化代码。我用MPLAB X IDE V2.30和声V1Y03Y01编译器XC32 V1.33在这个代码中,SPI初始化没有被编译器考虑,为了纠正这个问题,我把优化A 0,用这个C我的程序工作得很好。现在我有了相同的程序,但是用MPLAB X IDE V3.55和谐V1Y08Y01 01 XC1.42编译器,当我把优化0的程序给了我很多错误。我怎么解决这个问题,以便我的代码全部被读取?谢谢你的回复。
以上来自于百度翻译 以下为原文 Hi, I have a problem with my PIC of lis not the line of SPI initalisation code. I had a project with MPLAB X IDE v2.30 HARMony v1_03_01 compiler XC32 v1.33 In this code, the SPI initialization was not taken into account by the compiler, to correct this problem I put the optimization a 0, with this configuration my program worked perfectly. Now I have the same program, but with MPLAB X IDE v3.55 Harmony v1_08_01 XC1.42 compiler, when I put the optimization has 0 the program gives me a lot of error. How do I fix this problem so that all my code is read? Thank you for your reply. |
|
相关推荐
19个回答
|
|
|
|
|
|
我没有错。但是,当我处于调试模式时,它不会读取下面的行:[lt;字体] [&字体]
以上来自于百度翻译 以下为原文 I have no mistake. But when I'm in debug mode it will not read the following line: [ // uint32_t config = SPI_OPEN_MODE8 | SPI_OPEN_ON | SPI_OPEN_CKP_HIGH | // SPI_OPEN_MSTEN ; // FT800 < 11MHz Choix 10 MHz PLIB_SPI_Disable(KitSpi1); PLIB_SPI_BufferClear(KitSpi1); PLIB_SPI_StopInIdleDisable(KitSpi1); PLIB_SPI_PinEnable(KitSpi1, SPI_PIN_DATA_OUT); PLIB_SPI_CommunicationWidthSelect(KitSpi1, SPI_COMMUNICATION_WIDTH_8BITS); // Config SPI clock PLIB_SPI_BaudRateSet(KitSpi1, SYS_CLK_FREQ, 10000000); // Config polarité traitement des signaux SPI // pour input à confirmer // Polarité clock OK // Phase output à confirmer PLIB_SPI_InputSamplePhaseSelect(KitSpi1, SPI_INPUT_SAMPLING_PHASE_IN_MIDDLE ); PLIB_SPI_ClockPolaritySelect(KitSpi1, SPI_CLOCK_POLARITY_IDLE_HIGH); PLIB_SPI_OutputDataPhaseSelect(KitSpi1, SPI_OUTPUT_DATA_PHASE_ON_IDLE_TO_ACTIVE_CLOCK); PLIB_SPI_MasterEnable(KitSpi1); PLIB_SPI_FramedCommunicationDisable(KitSpi1); PLIB_SPI_Enable(KitSpi1); // SpiChnOpen(PicSpi1, config, 4); // 20 Mhz } |
|
|
|
“不读下面的行”是什么意思?你得到了什么错误?
以上来自于百度翻译 以下为原文 What does "not read the following line" mean? What error do you get? |
|
|
|
我没有错误。但是,当我处于调试模式时,它不会读取下面的行:(抱歉)编译时没有错误。但是在调试模式中,我注意到它不停在这些代码行上。因此,没有SPI初始化发生。在以前的版本中,我必须用优化0来纠正这个错误。但现在我不能再这样了。(涉及新的MPLAB X IDE 3.55或XC32编译器1.42)。
以上来自于百度翻译 以下为原文 I have no mistakes. But when I'm in debug mode, it will not read the following lines: (sorry) No errors when compiling. But in debug mode I notice that it does not stop on these lines of codes. Therefore no SPI initialization occurs. In a previous version I had to correct this error with the optimization has 0. but now I can no longer. (Involves the new MPLAB X IDE 3.55 or the XC32 compiler 1.42.) |
|
|
|
当启用优化时,不是每一行C都有相应的汇编指令,可以与之匹配。这并不意味着功能还没有完成。你检查过寄存器是否已经初始化了吗?可能是你在追逐一个不存在的问题。
以上来自于百度翻译 以下为原文 When optimisation is enabled, not every line of C has a corresponding assembler instruciton it can be matched to. That doesn't mean the functionality has not been done. Have you checked if the register have in fact been initialised? It could be you are chasing a problem that does not exist. |
|
|
|
我用这个代码完全相同的问题,但是用MPLAB X IDE V2.30xC32编译器V1.33和声V1Y03Y01和我解决了优化的问题有0,除了用MPLAB X IDE 3.55编译器V1.42和和声V1Y08Y01我不能激活优化有0。所以,有一个问题。我不知道微芯片开发者的变化,但无论如何,它改变了一些东西,因为它不再工作了。所以,如果有人能告诉我为什么在我的代码中放置断点,程序不会像它那样停在它上面。谢谢你的回答。有点恼火。
以上来自于百度翻译 以下为原文 I had exactly the same problem with this code but with MPLAB X IDE v2.30 XC32 compiler v1.33 harmony v1_03_01 and I solved the problem with the optimization has 0 except that with MPLAB X IDE 3.55 compiler v1 .42 and harmony v1_08_01 I can not activate the optimization has 0. So yes there is a problem. I do not know what the microchip developer changes but in any case it changes something because it does not work anymore. So if anyone can tell me why when I put a breakpoint in my code, the program does not stop on it as it should. Thank you in advance for your answer. Desloe a little annoyed. |
|
|
|
要补充的是,当优化启用时,频繁改变的变量必须是易失性存储类型。
以上来自于百度翻译 以下为原文 Want to add that when optimization enabled the variable which are frequently changing must have to be volatile storing type. |
|
|
|
|
|
|
|
要补充的是,当优化使频繁改变的变量必须是易失性存储类型时,“频繁改变”不是标准。如果不优化,变量就不会是“可观察的”(除非你使它变得不稳定)。这并不能阻止代码工作。一个写在中断服务内部,但在同一中断服务之外的代码中读取的变量,必须标记为易失性,或者代码可能发生故障。
以上来自于百度翻译 以下为原文 Want to add that when optimization enabled the variable which are frequently changing must have to be volatile storing type. "Frequently changing" is not the criteria. A variable that never changes may not be "watchable" (unless you make it volatile), if optimisation elinitaes it altogether. That doesn't stop the code working. A variable which is written to inside an interrupt service, but read by code outside the same interrupt service, MUST be marked volatile, or your code can misfunction. Just "frequently changing" does not require volatile. |
|
|
|
挥发或不管怎样。调试器必须停止在这行上,因为在旧版本中它停止了。
以上来自于百度翻译 以下为原文 Volatil or no matter what. The debugger must stop on this line because on my old version it stopped. |
|
|
|
你说的“不能激活优化0”是什么意思?您应该能够使用正在使用的编译器设置优化0。
以上来自于百度翻译 以下为原文 what do you mean by "not been able to activate optimization 0"? you should be able to set optimization 0 with the compiler you are using. |
|
|
|
编译器有几种方法可以尝试优化代码。循环展开,死代码消除,常数折叠和常见的子表达式消除,只是举几个例子。这实际上取决于编译器所使用的优化算法,它可能会从编译器的一个版本变成另一个版本。很有可能,随着优化的开启,源代码的一些行将被优化,因此断点不会被放置在源代码的优化行上。然而,这并不一定意味着CPU不执行该功能。如果你真的想让断点命中代码行(如果你试图调试一段代码的话可能是这样的话),那么你可以尝试将变量定义为C表达式中的易失性。
以上来自于百度翻译 以下为原文 There are several ways in which a compiler may try to optimize the code. Loop unrolling, dead code elimination, constant folding and common sub-expression elimination, just to name a few. It really depends on the optimization algorithm used by the compiler, which may change from one version of compiler to another. It is very likely that with the optimization turned on, some of the lines of source code will be optimized and hence the break-point will not hit when placed on the optimized lines of source code. This however, does not necessarily mean that the functionality is not executed by the CPU. If you really want to have the break-point hit the line of code (which may be the case if you are trying to debug a piece of code), then you may try by defining the variable as volatile in the C expression. |
|
|
|
是的,但这不是他不读的变量。这些函数是函数。我不知道如何在易失性中赋予函数。
以上来自于百度翻译 以下为原文 Yes, but it's not variables that he does not read. These are functions. I do not see how to give functions in volatile. |
|
|
|
这是不正确的,所以不要做出这样简单的假设。如果你想得到真正的帮助,请显示真正的代码,包括它正在调用的函数的内容。
以上来自于百度翻译 以下为原文 This is simply not true so don't make such simplistic assumptions. If you want to get real help, show the real code, including the contents of the function it is calling. |
|
|
|
我同意QHB。有这么多的原因,为什么这不是真的。例如,不同的编译器版本可以以不同的方式进行优化。对于我的代码,我几乎不可能在长的PLBIQ函数序列中设置断点。这些函数都是内联函数,调用其他内联函数,而编译器跳转到这些内联函数中的一个。如果您想设置断点,那么尝试添加一个“nop-());在您的PLBIGL调用的前面设置一个断点,然后一步一步地越过它。
以上来自于百度翻译 以下为原文 I agree with qhb. There are so many reasons, why this is not true. Just for example different compiler versions can optimize in different ways. For my code, I can almost never set breakpoints at a long sequence of PLIB_ functions. Those functions are all inlined functions calling other inline functions, and instead the compiler jumps to one of those inline functions. If you want to set a breakpoint, then try adding a _nop(); in front of your PLIB_ calls and set a breakpoint to that, and go step by step over it. |
|
|
|
我调用我的函数:SPIXInITFT800();然后我应该在这里停止:[lt;字体] [lt;字体],但是它在这里[[lt;字体] [&字体] ]。
以上来自于百度翻译 以下为原文 I call my function: SPI_InitFT800 (); Then I should stop here: void SPI_InitFT800(void) { // uint32_t config = SPI_OPEN_MODE8 | SPI_OPEN_ON | SPI_OPEN_CKP_HIGH | // SPI_OPEN_MSTEN ; // FT800 < 11MHz Choix 10 MHz PLIB_SPI_Disable(SPI_ID_1); PLIB_SPI_BufferClear(SPI_ID_1); PLIB_SPI_StopInIdleDisable(SPI_ID_1); PLIB_SPI_PinEnable(SPI_ID_1, SPI_PIN_DATA_OUT); PLIB_SPI_CommunicationWidthSelect(SPI_ID_1, SPI_COMMUNICATION_WIDTH_8BITS); // Config SPI clock PLIB_SPI_BaudRateSet(SPI_ID_1, SYS_CLK_FREQ, 10000000); // Config polarité traitement des signaux SPI // pour input à confirmer // Polarité clock OK // Phase output à confirmer PLIB_SPI_InputSamplePhaseSelect(SPI_ID_1, SPI_INPUT_SAMPLING_PHASE_IN_MIDDLE ); PLIB_SPI_ClockPolaritySelect(SPI_ID_1, SPI_CLOCK_POLARITY_IDLE_HIGH); PLIB_SPI_OutputDataPhaseSelect(SPI_ID_1, SPI_OUTPUT_DATA_PHASE_ON_IDLE_TO_ACTIVE_CLOCK); PLIB_SPI_MasterEnable(SPI_ID_1); PLIB_SPI_FramedCommunicationDisable(SPI_ID_1); PLIB_SPI_Enable(SPI_ID_1); // SpiChnOpen(PicSpi1, config, 4); // 20 Mhz } [ [ { _SFR_BIT_CLEAR( _SPI_ENABLE_CONTROL_VREG( index ), _SPI_ENABLE_CONTROL_POS( index ) ); } |
|
|
|
这就是我正在考虑的:这是一个内联函数。还有下一个:因此,调试器跳转到内联函数。没有函数调用开销,也没有为此生成代码。调试器不能停在某个地方,这根本就不存在。根据我的经验,这是调试器的正常行为。编辑:POST改进。注意:显示代码来自和声2.0.3版。
以上来自于百度翻译 以下为原文 That is what I am taking about: PLIB_INLINE_API void PLIB_SPI_Disable(SPI_MODULE_ID index) { SPI_Disable_Default(index); } This is an inline function. And also the next one: #define PLIB_TEMPLATE PLIB_INLINE [...] PLIB_TEMPLATE void SPI_Disable_Default( SPI_MODULE_ID index ) { spi_registers_t volatile * spi = ((spi_registers_t *)(index)); spi->SPIxCONCLR = SPIxCON_ON_MASK; } Therefore, the debugger jumps into the inlined function. There is no function call overhead and no code is generated for this. And the debugger can't stop at something, which is simply not there. To my experience that's normal behavior of the debugger. Edit: Post improved. Note: Displayed code is from Harmony 2.0.3 version. |
|
|
|
当我使用优化时有0。我有很多错误,看起来像这样:
以上来自于百度翻译 以下为原文 When I use optimization has 0. I have a multitude of error that looks like this: build/pic32mx_eth_sk/production/_ext/1164207549/dns.o: Link Error: Could not allocate section .text.TCPIP_DNS_GetIPAddressesNumber, size = 344 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/udp.o: Link Error: Could not allocate section .text.TCPIP_UDP_DestinationIPAddressSet, size = 340 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/dhcp.o: Link Error: Could not allocate section .text.TCPIP_DHCP_Disable, size = 340 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/dhcp.o: Link Error: Could not allocate section .text._DHCPPacketFilter, size = 340 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/tcpip_commands.o: Link Error: Could not allocate section .text._Command_BIOSNameSet, size = 340 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/tcpip_manager.o: Link Error: Could not allocate section .text._TCPIPStackManagerSignalClear, size = 340 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/ipv6.o: Link Error: Could not allocate section .text.TCPIP_IPV6_AddressFind, size = 336 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/icmpv6.o: Link Error: Could not allocate section .text.TCPIP_ICMPV6_HeaderNeighborAdvertisementPut, size = 336 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/smtp.o: Link Error: Could not allocate section .text.FindEmailServer, size = 336 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/tcpip_commands.o: Link Error: Could not allocate section .text._Command_DefaultInterfaceSet, size = 336 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/2136608937/u***_device.o: Link Error: Could not allocate section .text.USB_DEVICE_Open, size = 336 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1373386656/system_interrupt.o: Link Error: Could not allocate section .text._IntHandler_ETHMAC, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1697634946/drv_ethmac.o: Link Error: Could not allocate section .text.DRV_ETHMAC_Tasks_ISR, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/521481140/drv_ethphy.o: Link Error: Could not allocate section .rodata, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/521481140/drv_ethphy.o: Link Error: Could not allocate section .text._DRV_ETHPHY_SetupPhaseNegotiate_SubPhase6, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/521481140/drv_ethphy.o: Link Error: Could not allocate section .text._DRV_ETHPHY_NegCompletePhaseAN_Restart, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1891376032/sys_command.o: Link Error: Could not allocate section .text.SYS_CMD_READY_TO_READ, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/tcpip_manager.o: Link Error: Could not allocate section .text.TCPIP_STACK_AddressServiceEvent, size = 332 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1891376032/sys_command.o: Link Error: Could not allocate section .text.SYS_CMDIO_ADD, size = 328 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/arp.o: Link Error: Could not allocate section .text._ARPProcessRxPkt, size = 328 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/oahash.o: Link Error: Could not allocate section .text.TCPIP_OAHASH_EntryLookup, size = 328 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1360937237/custom_http_app.o: Link Error: Could not allocate section .text.TCPIP_HTTP_Print_reboot, size = 324 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/dns.o: Link Error: Could not allocate section .text._DNSCompleteHashEntry, size = 324 bytes, attributes = code build/pic32mx_eth_sk/production/_ext/1164207549/zero_conf_link_local.o: Link Error: Could not allocate section .text.TCPIP_ZCLL_Initialize, size = 324 bytes, attributes = code _fputc_simple.o: Link Error: Could not allocate section .text.fputc, size = 324 bytes, attributes = code |
|
|
|
不幸的是,优化0增加了代码的大小。它不适合您的代码段。您可以尝试删除/注释出当前调试不重要的部分。从错误列表中,可以添加大小以查看需要多少内存才能“免费”。另外,尝试只对那些文件应用“优化0”,在这些文件中需要通过/设置断点。
以上来自于百度翻译 以下为原文 Unfortunately optimization 0 increases the size of your code. It does not fit into your code sections. You could try to remove / comment out sections which are not important for your current debugging. From the error list you could add the sizes to see how much memory you need to "free". Alternatively try to apply "optimization 0" only for those files, where you need to step through / set breakpoints |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
777浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
676浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 05:58 , Processed in 1.703226 second(s), Total 112, Slave 96 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号