打印
[综合信息]

ARM Cmpiler V6.6编译的程序运行时出错

[复制链接]
586|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 evan6688 于 2020-7-9 14:33 编辑

同一工程设置ARM Cmpiler为V6.6时编译的程序运行时出错,V5.6编译的代码运行正常。
MCU  HC32L136K8T
hc32l13x_ddl_Rev1.8.0 Lite 样例工程中添加修改
V5.6 程序串口信息
Usart On V104.1!  
Dev Addr:20000020Addr:52,20000020
Addr:52,20000020
Addr:52,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020
Addr:54,20000020

V6.6 程序串口信息
Usart On V104.1!  
Dev Addr:200000c0Addr:52,200000c0
Addr:52,200000c0
Addr:52,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:54,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
Addr:00,200000c0
API Status: -20 : Control Interface Error  
VL53L0X Error!!!


Addr:54,200000c0
54是VL5310X的I2C地址,200000c0是存放I2C地址的结构体首地址。
运行过程中结构体变量中的数据发生了改变,

结构体的定义和使用//结构体的定义
//结构体的定义
typedef struct {
    VL53L0X_DevData_t Data;              /*!< embed ST Ewok Dev  data as "Data"*/
    /*!< user specific field */
    uint8_t   I2cDevAddr;                /*!< i2c device address user specific field */
    uint8_t   comms_type;                /*!< Type of comms : VL53L0X_COMMS_I2C or VL53L0X_COMMS_SPI */
    uint16_t  comms_speed_khz;           /*!< Comms speed [kHz] : typically 400kHz for I2C           */


} VL53L0X_Dev_t;




typedef VL53L0X_Dev_t* VL53L0X_DEV;


//结构体变量定义
static VL53L0X_Dev_t vl53l0x_dev;
status = VL53L0X_ReadMulti(&vl53l0x_dev,0,buffer,30);


//数据读出函数
VL53L0X_Error VL53L0X_ReadMulti(VL53L0X_DEV Dev, uint8_t index, uint8_t *pdata,uint32_t count)
{
       
         VL53L0X_Error Status = VL53L0X_ERROR_NONE;
       
         int32_t status_int;
       
         uint8_t deviceAddress;
       
         if(count >=VL53L0X_MAX_I2C_XFER_SIZE)
         {
                 Status = VL53L0X_ERROR_INVALID_PARAMS;
         }
         
         deviceAddress = Dev->I2cDevAddr;
         printf("Addr:%02x,%08x\n",deviceAddress,Dev);
         
         status_int = VL53L0X_read_multi(deviceAddress, index, pdata, count);
         
         if(status_int!=0)
           Status = VL53L0X_ERROR_CONTROL_INTERFACE;
         
         return Status;
       
}



仿真调试截图
结构体指针中的所有数据在return Status时发生改变;



使用特权

评论回复
评论
suncl110 2020-7-13 17:44 回复TA
我的即使程序调试的通,运行时也会出现莫名的问题,同样代码放IAR上运行正常.建议你使用IAR吧,如果嫌IAR界面丑,用ECLIPS+IAR+jlink方式很好. 
沙发
martinhu| | 2020-7-14 16:40 | 只看该作者
KEIL的例子,默认的是这个编译器吧

这个应该编译没问题,你说的那个没有试过

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝