Abstract: In the data acquisition equipment as well as has in the related function instrumental design, the data memory and the transmission are a very important link, this article in the success practice foundation, introduced that after micro controller MSP430F449 realizes the data gathering data storage and with the superior machine data communication related content. In the article has given the practical hardware circuit and the partial software code, explained some links which in detail needs to pay attention in the data storage.
Key word: MSP430, USB, I2C
In the data acquisition and in the metering equipment portable equipment, the data storage and the transmission are the inevitable questions particularly, in recent years TI Corporation promoted low power loss micro controller MSP430, caused the huge transformation in the instrumental design and the manufacture domain, the new controller and the large capacity serial storage’s application enhanced the product performance greatly. This article mainly solves two problems
1 solution after MSP430 gathering data and EEPROM24C256 data interface question, is also the data storage question;
2 solve EEPROM and the superior machine (ordinary microcomputer) data communication question, also after is the memory data upload question.
First makes the simple introduction to the main integrated circuit
MSP430F449 synopsis
MSP430F449 is in the MSP430 series one kind, the MSP430 series is one kind has the integration rate to be high, the function is rich, power loss low status characteristic 16 monolithic integrated circuits. Its integrated debugging environment Embedded Workbench provided the good C language to develop the platform. In the design has chosen MSP430F449 based on the procedure complexity and the procedure capacity big request, this model of chip has the 64K program memory, may satisfy the majority of pluralities of controls the need; Its seal 100-PIN QFP has the good interchangeability, with chips and so on MSP430F437, MSP430F435 has the completely consistent base pin to be possible to carry on the reasonable choice in the procedure quantity.
24C256 synopsis
24C256 is supports I2C agreement serial EEPROM, the capacity 32768 bytes.

The above is the 24C256 base pin chart, A0, A1, A2 constitutes memory’s physical address, takes on the I2C main line to differentiate the different memory’s control address, may simultaneously connect 8 equipment on the I2C main line. WP writes the protection, the high level will forbid to the component to write the operation; SCL and SDA are the data transmission pilot wires, SCL is a clock, SDA is the bidirectional data line, uses for to complete the data read-in and reads out, the data transmission carries the SCL coordination according to the I2C agreement’s request by the clock to complete together.
CP2102 synopsis
CP2102 is USB to the UART bridge circuit, completes the USB data and the UART data transformation, the electric circuit connection is simple, the data transmission is reliable, transforms the USB data format the lower position machine serial data, facilitates realizes the data communication, through moves this chip driver in the superior machine to be possible to defer to the USB data the simple serial port to carry on the read-write operation programming to be simple, the operation is flexible.

Figure 1 MSP430F449 connection schematic diagram
The above is MSP430F449 and EEPROM as well as the CP2102 connection schematic diagram, this article lies in the introduction data acquisition process to complete the later data storage and the data transmission with emphasis.
Data gathering are many and varied, may pass through the internal ADC switch to carry on gathering to the simulation quantity, may also through the independent port pilot wire to the special sensor for instance temperature sensor, the pressure transmitter and so on carry on the data conversion, this not the content which introduced as this article. After this article is mainly aims at the different gathering process completes, the data memory and transmission processing.
Data automatic memory objective request
In many measuring processes, not only request read simple measuring appliance value, moreover also needs to carry on the science to a period of time data the analysis and processing obtains the forecast and the analysis goal. In this case, possibly requests the measuring time to be long, the gathering request carries on automatically, does not need the artificial value to defend, therefore the data must save automatically; Another reason, gathers the data the frequency to be quite high, human’s observation cannot satisfy the actual need, this requests to the gathering data to carry on the effective memory.
The integrated circuit chooses reasonably
Had the large capacity FLASH chip already to obtain the widespread application, but this kind of chip mouth line were many, needed to take the many controller resources, in controlled the periphery component to be many, in the connection complex situation, the portable instrument function entire, the volume was specially small, to simplify the peripheral circuit, in did not affect the reserves in the situation, had I2C connection serial EEPROM to become the best choice.
24C256 programmed control principle
24C256 has I2C the connection 512×64 memory, in the data memory process besides follows the I2C agreement to logic, easiest to neglect, and easiest to cause the question which makes a mistake is the memory address question.
the 24C256 data capacity is 32768, namely may save effective byte count. Therefore its address is 16 trueing numbers, the range of validity is 0~32768, the data byte saves for the unit, in 16 bit address valid data only then 15, low 6 (0~5) the bit address expression’s capacity is 0~63, then continual 9 (6~14) the bit address expression page number’s scope is 0~511, in the data saves in continuously the process, in the same page, the memory address completes the accumulation process automatically; Data when different page’s memory, the address cannot accumulate automatically, if does not make correct processing, the data which from this page the data will start the address which makes a fresh start to cover already existed. For example, what the address is 63 (binary code 111111) expressed is the 0th page of last storage space, the address 64 (binary code 1,000000) expressed the 1st page most starts storage space. In the current memory address is 63:00, if this component is in continuously under the storage pattern, the data will make a mistake.
What is the reason? the 24C256 support data’s continual memory, biggest storage quantity is 64 namely page of contents, if has surpassed this limit in the address selection, the data will cover the position which this page will start to save, this will create the data the mistake, in use, although the data will be the paging memory, but in formally will be the continuous data, therefore in the memory will not need specially in the area paging address and the page the address.
In continual saves, although the data each time saves quantity is smaller than 64, the data also possibly makes a mistake, for example each time saves quantity is 11, the address change is 0,11,22,33,44,55,66 ……, seems does not have what question, the address is defers to each time 11 increasings, however saves the result has made a mistake, what is the reason? The space which 55 start in the address is unable to provide the continual 11 page internal storage space, when the address will increase to 63 later data makes a fresh start from this page of 0 addresses, will thus cause the information storage the mistake. The effective solution is if uses continuously the storage pattern, the address arrangement must make memory block’s size is 64,32,16,8,4,2 in addition cannot use the continual address to save. If in data acquisition’s valid data position is smaller than 64, for instance each time gathers the result is 30 bytes, must defer to continuously under the storage pattern 32 saves for the unit, the insufficient byte makes up zero processing.
The following is the 24C256 data transmission basic control module
Ø Time delay processing module
void IIC_Delay(void)
{
_NOP();
_NOP();
_NOP();
}
Ø Starts the I2C module
void start_IIC(void) // Starts I2
{
P2OUT&=0xf9; // establishes the P2 output
P2DIR&=0XFD; //SDA =1, on pulls the resistance to cause P2.1 is H, FD=1111,1101
P2DIR&=0XFB; //SCL =1 FB=1111,1011
P2DIR|=0X02; // SDA=0
P2DIR|=0X04; // SCL=0
}
Ø Stops the I2C module
void stop_IIC(void) //
{
P2DIR|=0X02; //SDA=0
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
P2DIR&=0XFD; //SDA=1, On pulls the resistance to cause P2.1 is H, FD=1111,1101
IIC_Delay();
P2DIR|=0X04; // SCL=0
}
Ø Transmission “0” module
void send_zero(void) //
{
P2DIR|=0X02; // SDA=0
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
P2DIR|=0X04; // SCL=0
}
Ø Transmits 1 module
void send_one(void) //
{
P2DIR&=0XFD; //SDA=1, On pulls the resistance to cause P2.1 is H, FD=1111,1101
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
P2DIR|=0X04; // SCL=0
}
Ø Transmission individual character symbol data
void send _char (unsigned char data_out) //
{
unsigned char i, tmp=0×80;
for (i=0; i<8; i )
{
if ((data_out & tmp) >0)
send_one();
else
send_zero();
tmp/=2;
}
}
Ø Reads the single character data
unsigned char read_char(void)
{
unsigned char i, tmp=0×80;
unsigned char data1=0;
for (i=0; i<8; i )
{
P2DIR&=0XFD; //SDA=1, 11111101
IIC_Delay(); //
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
if((P2IN&0×02)>0×00)
{
data1|=tmp;
}
P2DIR|=0X04; // SCL=0
IIC_Delay();
tmp/=2;
}
return data1;
}
Ø Inspection answering signal module
void iic_ACK(void)
{
ack_flag=0×00;
P2DIR&=0XFD; //SDA=1, FD=1111,1101
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
while((P2IN&BIT1)==BIT1);
P2DIR|=0X04; // SCL=0
IIC_Delay();
}
Ø Refuses to reply the module
void iic_NACK(void) {
P2DIR&=0XFD; //SDA=1,
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
P2DIR|=0X04; // SCL=0
IIC_Delay();
P2DIR|=0X02; // SDA=0
IIC_Delay(); //
}
Ø Writes the continuous data module
void WriteNbyte (unsigned char *p, unsigned int addr, unsigned char number)
{
start_IIC();
send_char(0xa2);
iic_ACK();
send_char(addr/256); //high address byte
iic_ACK();
send_char(addr%6);
iic_ACK();
do
{
send_char(*p);
p ;
iic_ACK();
}
while (–number);
stop_IIC();
delay(10);
}
Ø Transmission reply module: ACK (LOW)
void S_ACK(void)
{
P2DIR|=0X02; // SDA=0
IIC_Delay();
P2DIR&=0XFB; //SCL=1 FB=1111,1011
IIC_Delay();
P2DIR|=0X04; // SCL=0
IIC_Delay();
}
Ø Reads the character module continuously
void ReadNbyte (unsigned char *p, unsigned int addr, unsigned char number)
{
start_IIC();
send_char(0xa2);
iic_ACK();
send_char(addr/256);
iic_ACK();
send_char(addr%6);
iic_ACK();
start_IIC();
send_char(0xa3);
iic_ACK();
do
{
*p=read_char();
p ;
if (number! =1)
S_ACK(); //send ACK
}
while (–number);
iic_NACK();
stop_IIC();
}
Data transmission
The data transmission is the memory arrives at computer’s efficient path in the EEPROM data, what the data uploads to the computer is most commonly used is serial (RS232) the connection, because now USB counting unceasingly mature, may facilitate through USB realizes the data transmission quickly, moreover may satisfy the speed and the equipment outward appearance request, but the USB driver design is the quite complex work, in this example uses the simple bridge circuit, the UART connection’s data after the CP2102 bridge joint, realizes the data USB transformation directly, changes into from the 430F449 asynchronous serial port output’s data automatic extension conforms to USB the agreement data direct connection computer’s USB mouth, the superior machine applicationThe procedure may operate the serial port equally direct read-write port data likely through the CP2102 driver.
Conclusion
The above hardware design is quite simple reliably, may imitate to the same type control chip, the software code also similarly has the good portability, so long as controls the clock and the data port and the procedure software establishment identically then.
Reference:
1st, MSP430 series 16 ultra low power loss monolithic integrated circuit practice and system design “Tsinghua University Publishing house”
2nd, MSP430 series monolithic integrated circuit connection counting and system design example “Beijing Astronautics Aviation University Publishing house”
3rd, MSP430 the series monolithic integrated circuit C language programming and develops “Beijing Astronautics Aviation University Publishing house”