小弟设计遇到了一个诡异的问题 当我将 third(B.b);批注后,CANBOX可以接收到Data=8的信息,但当 third(B.b); 取消批注就无法从我自己设计的窗口Print出CAN收到的值 但从Debugmode的watch window观察Data依然等于8,说明程序是有继续执行的。 有点难形容,用很简略的说法就是, third(B.b); 批注与否会影响到CAN的接收,但watchwindow又可以看见运算结果都是正确的(ex.Data=8),不知道何解..... 还请各位帮忙分析一下,这比较像是function的设计bug,还是内存配置的bug呢? 程序架构为 #include <stdlib.h> #include <stdio.h> float input={1,2,3,4,5}; //随意几个浮点数 ///////////struct宣告/////////// struct A{ floattest } a; struct B{ floattest } b; struct C{ floattest } c; ///////////////////////////// ///////////算法function 设计/////////// float first(float input[]) {算法内容} float second(float input[]) {算法内容} float third(float input[]) {算法内容} //////////////////////////////////////////// static CanTxMsgTypeDef TxMessage; hcan1.pTxMsg = &TxMessage; int main(void) { first(input); ///得到A.a的值 second(A.a); ///得到B.b的值 third(B.b); ///得到C.c的值 hcan1.pTxMsg->Data = 0x08; while (1) { HAL_CAN_Transmit(&hcan1, 0); HAL_Delay(50); } }
|