|
本帖最后由 wangxj_nemo 于 2012-9-5 16:46 编辑
STM32芯片,72M速度,RAM仿真方式在串口能出来想要的数据,但是RELEASE版本在- //method 1 no works,why?
- for(uint8_t k = 0; k < 4; k++)
- DebugStringAppend(&__gDbgInfo, wuSlave24GRxBuffer.rxHu[currentLayer].rxBuffer[k]);
复制代码 的就出不来数据,在- //method 2 works,but no good for display
- uint8_t k = 0;
- for(; k < 4; k++)
- __gDbgInfo.Ch[k] = wuSlave24GRxBuffer.rxHu[currentLayer].rxBuffer[k];
- __gDbgInfo.Ch[k++] = '\n';
- __gDbgInfo.Ch[k++] = '\0';
复制代码 就可以,,貌似优化的问题,- DBG_INFO_T __gDbgInfo 加volatile
复制代码 也用过了就是不行,请教大牛这是为什么?
背景代码如下,DebugStringAppend是在中断中调用.用于转HEX数据为ASSIIC字符串,方便显示- typedef enum DBG_TYPE_T{
- DBG_IDLE = 0,
- DBG_INITIALING = 1,
- DBG_INIT_OVER = 2,
-
- }DBG_TYPE_T;
- static char hexString[] = "0123456789ABCDEF";
- #pragma pack(1)
- typedef struct DBG_INFO{
- uint8_t Ch[200];
- uint8_t len;
- DBG_TYPE_T type;
- }DBG_INFO_T;
- DBG_INFO_T __gDbgInfo = { {'\0'}, 0, DBG_IDLE};
- void DebugStringInit(DBG_INFO_T *str)
- {
- str->Ch[0] = '\0';
- str->len = 0;
- }
- void DebugStringAppend(DBG_INFO_T *dbg,char c)
- {
- if(dbg->len != 0)
- {
- dbg->len -= 2;
- dbg->Ch[dbg->len++] = ' ';
- }
-
- dbg->Ch[dbg->len++] = hexString[(c & 0xF0) >> 4];
- dbg->Ch[dbg->len++] = hexString[(c & 0x0F) >> 0];
-
- dbg->Ch[dbg->len++] = '\n';
- dbg->Ch[dbg->len++] = '\0';
-
- }
- if(__gDbgInfo.type != DBG_IDLE)
- {
- DebugInfoOut(__gDbgInfo.type);
- __gDbgInfo.type = DBG_IDLE;
- }
- void DebugInfoOut(DBG_TYPE_T infoType)
- {
- switch( infoType )
- {
- case DBG_IDLE:
- break;
- case DBG_INITIALING:
- DbgSysInitial();
- break;
- }
- }
- void DbgSysInitial(void)//1 初始化
- {
- const char *pstr = sysInitial;
- while(*pstr){
- while(USART_GetFlagStatus(SYS_DBG_UART,USART_FLAG_TXE)==RESET);
- USART_SendData(SYS_DBG_UART, *pstr++);
- }
- }
复制代码 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|