完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
下面的代码是从应用程序的其余部分中的不同位置调用的。它在调试过程中运行良好。然而,当我构建和引导程序(我们使用USB主机引导加载程序从一些旧的MLE有它)似乎会引起一些问题,我的LCD不工作(主线),但某些中断仍然火,我可以测试。这就像挂上主线代码,但允许其他中断工作。为什么它只有在引导加载时才会发生,对我来说是个谜,也是我想回答的第一件事。此外,引导加载的版本必须被优化以适合,1级的伎俩,这就是我现在正在运行。MCU是PIC24FJ128GB108,MPLABX 4.05,已经尝试过XC1.30,1.31,1.32。 以上来自于百度翻译 以下为原文 The following code is called from various locations within the rest of the application. It works well during debugging. However, when I build and bootload the program (we use the USB host bootloader from some older MAL that had it) It seems to cause some issue where my LCD doesn't work (mainline), but certain interrupts still fire that I can test. It's like it's hanging the mainline code but allowing other interrupts to work. Why it happens only when bootloaded is a mystery to me and the first thing I'd like help answering. Also, the bootloaded version must be optimized to fit, level 1 does the trick so that's what I'm running for now. MCU is pic24fj128gb108, mplabx 4.05, have tried xc 1.30,1.31,1.32. #include #include #include #include "version.h" #define SP_TX_BUF_LEN 100 #define SP_RX_BUF_LEN 100 volatile char* sp_tx_w; volatile char* sp_tx_r; volatile char sp_tx_buf[SP_TX_BUF_LEN]; volatile char* sp_rx_w; volatile char sp_rx_buf[SP_RX_BUF_LEN]; void init_sp(void){ _LATG7 = 1; PMD3bits.U3MD = 0; //enable U3 Module U3MODE = 0; //disable and default tranciever U3MODEbits.PDSEL = 0b00; //8 bit data, even parity U3MODEbits.STSEL = 0; //one stop bit U3STA = 0b0000000000000000; //interrupt after send (ie all done) U3MODEbits.BRGH = 0; U3BRG = 51; IFS5bits.U3RXIF = 0; //Clear Rx interrupt flags IPC20bits.U3TXIP = 0x05; //keep from getting hung in sp_send when called from another interrupt IFS5bits.U3TXIF = 0; //TX flag clear IEC5bits.U3TXIE = 0; //TX interrupt enabled on loading of 1st character U3MODEbits.UARTEN = 1; //Enable UART U3STAbits.UTXEN = 1; //enabling the uart tx sp_tx_w = sp_tx_buf; sp_tx_r = sp_tx_buf; } unsigned int sp_send(char* msg){ static bool locked = 0; if(locked){ return 1; } locked = 1; while(*msg != ' |