2622 views|6 replies

6366

Posts

4936

Resources
The OP
 

MSP430 MCU Development Record (18) [Copy link]




This content is originally created by EEWORLD forum user tiankai001. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source. MSP430 MCU Development Record (18) Phenomenon: At the beginning of the function, an array is defined, and an initial value is assigned to all elements of this array, using the following statement.
  1. unsigned char ucRamToMemory[70]={0x08};
复制代码
However, when the data in this array is used in the function, it is found that only the value of the first array element in this array is 0x70, while the values of the remaining array elements are not 0x70. Test: Because when defining arrays in functions before, it is generally customary to initialize the initial values of all array elements to 0, and the following statement is often used.
  1. unsigned char ucKxAndVol[70]={0x00};
复制代码
In actual use, the initial value of all elements in the array is 0. This actually involves the knowledge of C language. In C language, when defining an array, if you want to set the initial value of all array elements to 0, you can use the above statement. However, if you want to set the initial value of the array element to non-zero data when defining it, you cannot use this statement. You can only assign values to the array elements separately, or use the following statement
  1. memset(RecData,0x58,100);//Set the values of the first 100 elements in the array to 0x58
复制代码
Verification: Because you want to set all the elements of the array to a non-zero value, assign values to all the elements in the array separately. After verification, everything is normal. Use the memset statement to set the array elements to non-zero values. After verification, everything is normal. Remarks: When assigning values to array elements, please note that if you assign values to them at the same time as you define them, even if you assign the same data, if the value is not zero, you need to assign values one by one.
This post is from Microcontroller MCU

Latest reply

Okay, I will always pay attention to your posts, come on.  Details Published on 2018-12-25 14:40
 

2618

Posts

0

Resources
2
 
It’s really good to gain a little knowledge every day
This post is from Microcontroller MCU

Comments

I have made too many mistakes at work. Sharing them can serve as a warning to myself.  Details Published on 2018-12-21 09:50
 
 

6366

Posts

4936

Resources
3
 
alan000345 posted on 2018-12-21 09:26 A little knowledge every day is really good
I made too many mistakes at work, sharing them can serve as a warning to myself
This post is from Microcontroller MCU

Comments

Yeah, that’s really good.  Details Published on 2018-12-21 10:57
 
 
 

2618

Posts

0

Resources
4
 
tiankai001 Posted on 2018-12-21 09:50 There are too many mistakes made at work, sharing them can serve as a warning to myself
Yeah, that’s really good.
This post is from Microcontroller MCU
 
 
 

2618

Posts

0

Resources
5
 
Learn more, share more
This post is from Microcontroller MCU

Comments

I will continue to share later. Thank you for your support.  Details Published on 2018-12-25 11:12
 
 
 

6366

Posts

4936

Resources
6
 
alan000345 posted on 2018-12-25 09:51 I have learned a lot and I want to share more
I will continue to share later. Thanks for your support
This post is from Microcontroller MCU

Comments

Ok, I will keep following your posts. Come on.  Details Published on 2018-12-25 14:40
 
 
 

2618

Posts

0

Resources
7
 
tiankai001 posted on 2018-12-25 11:12 I will continue to share later, thank you for your support
Okay, I will always pay attention to your posts, come on.
This post is from Microcontroller MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list