BG4RFF 发表于 2017-3-24 00:10:21

STM8S使用STVD+COMSIC奇怪的问题

定义了

@eeprom unsigned char memoryProtected[] = {0x00,0xff,0xff,0xff };
unsigned char command;

本想这样赋值
memoryProtected[(command>>3)]|= (1<<(command&0x07));
结果CGSTM8崩溃
注册这行就没问题
然后就这样来试试

@eeprom unsigned char memoryProtected[] = {0x00,0xff,0xff,0xff };unsigned char command,TempAdd=0,TempValu=0;
                  TempAdd=(command&0x1f)>>3;
                  TempValu=1<<(command&0x07);
//                  memoryProtected|= TempValu;
去掉上一行的注册就崩溃
然后这样
memoryProtected|= TempValu;
memoryProtected|= TempValu;
memoryProtected|= TempValu;
memoryProtected|= TempValu;
都没有问题
请指点

sfd123-302670 发表于 2017-4-6 08:02:03

有什么奇怪的,内存溢出了!

wudianjun2001 发表于 2017-4-6 08:08:35

我用的8L052感觉EEPROM也有问题,频繁操作写的话程序偶尔会死掉

无薪税绵 发表于 2017-4-6 08:11:47

command>>3 
这里没有做防溢出处理。

ts2000 发表于 2017-4-6 08:41:24

还是用IAR吧,,,好用得多

anobodykey 发表于 2017-4-6 09:09:31

应该是你数组越界了吧

toofree 发表于 2017-4-6 10:01:43

如果像楼上几层说的是溢出的话,这样试试。
memoryProtected[(command>>3)&0x03]|= (1<<(command&0x07));

中山无雪 发表于 2017-4-6 10:34:57

sfd123-302670 发表于 2017-4-6 08:02
有什么奇怪的,内存溢出了!

是啊!!!

超界了!!!

五哥1 发表于 2017-4-6 11:17:18

帮顶,这个STM8用的少。

cldym 发表于 2017-4-6 14:02:40


command>>3 
这里没有做防溢出处理。
页: [1] 2
查看完整版本: STM8S使用STVD+COMSIC奇怪的问题