The program can run normally under Debug, but the normal compilation does not work normally

There is no problem compiling under KEIL. I am using the STM32 SPL library.

We’d need to see the code for that.

Do you mean that when you debug the program line-by-line it works, but if you just run it it doesn’t? Or that if you compile it without compiler optimizations (-Og or -O0) it runs but not with optimizations?

ok.

This is the two variables I use.

1 2

iic_comm_data_buff[0] = 0
iic_comm_data_buff[1] = 18

This is the function I am using. His function is to read the specified number of data from the iic_comm_data_buff array.the data_type is how many bytes of data are read

!

This is my operation, I want to read 2 bytes of data from the iic_comm_data_buff array, and then put it into Com1SetWordBuf_4x[2], but the result is not 18, but 254. I don’t know why.

89GS%24YCNUXD%7BD7NT%5DR8C50D