我有一个vectorx8,我想将它的值保存在XMEGA的EEPROM中,因为下面是我所做的工作:
............................
int16_t vec1[8];
int16_t vec2[8];
int16_t vec3[8];
int i = 0, j =1;
for ( i =0 ; i<8; i++){ // ini
vec1[i] = 23500;
vec2[i] = 20000;
vec3[i] = 20000;
}
for ( i =0; i<8 ; i++) {
eeprom_update_word (( uint16_t *)j++, vec1[i]);
eeprom_update_word (( uint16_t *)j++, vec2[i]);
eeprom_update_word (( uint16_t *)j++, vec3[i]);
}现在,当我尝试使用以下所保存的值时:.
int16_t tempX[8];
int j =2 ;
for ( i = 0 ; i < NUMBEROFSENSORS ; i++ ){
tempX[i] = (int16_t) eeprom_read_word(j);
j= j+3; // reading only vec1
printf(" j read Value is : %d \n",(int16_t)tempX[i]);
}我得到的是-13158而不是23500,所以我的问题是我在这里做错了什么?
把K转换成一个点,我得到这个输出:
read Value is : 2627 读取值是: 2714读值是: 23450读值是:-3584读值是: 31744读值是: 11008。
发布于 2015-06-08 13:21:11
将j定义为uint16_t * j。然后++操作将适当地增加它与2而不是1。你将不需要铸造:eeprom_update_word (j++, vec1[i])。
https://stackoverflow.com/questions/30710159
复制相似问题