[제품종류] IEC667Lite
[개발환경] Visual Studio 2008 C#
안녕하세요. SmartIIC_CSharp_IEC667 샘플을 통해 , 특정 데이터 주소에 특정 값을 입력하여, 저장 및 읽기가 되는 것을 확인했습니다.
제가 eeprom을 사용하여 하고자 하는 것은 생산이력을 저장시켜 놓으려 합니다. "DJ_231018_00021_13:42:33"이런 식으로요.
아래의 SmartIIC_CSharp_IEC667 예제에서, // ★ 로 된 구간은 위 생산이력을 읽고자 하여 작성한 코드입니다.
// 사용할 변수 선언
byte iSlaveAddress;
byte iMemAddress;
byte iData;
// ★ byte[] yData;
// Device의 Slave Address를 읽어 온다
iSlaveAddress = Convert.ToByte(labSlaveAddress.Text);
iMemAddress = Convert.ToByte(labAddress.Text);
// ATMEL사의 24C16의 Data Sheet를 참조 하세요.
// 시작조건 신호를 발생시킵니다.
smartIIC1.Start_Signal();
// SlaveAddress값을 데이터 송신합니다.
smartIIC1.Write_Byte(iSlaveAddress);
// MemAddress값을 데이터 송신합니다.
smartIIC1.Write_Byte(iMemAddress);
// 중지조건 신호를 발생시킵니다.
smartIIC1.Stop_Signal();
// 시작조건 신호를 발생시킵니다.
smartIIC1.Start_Signal();
// SlaveAddress값을 1과 연산하여 데이터 송신합니다.
smartIIC1.Write_Byte((byte)(iSlaveAddress | 1));
// 데이터를 읽어옵니다.(ACK 응답을 기다리지 않음)
iData = smartIIC1.Read_Byte(SmartX.SmartIIC.ACKSIG.NOACK);
// ★ yData = new byte[34];
// ★ for (int i = 0; i < 34; i++)
// ★ {
// ★ smartIIC1.Write_Byte((byte)(iSlaveAddress | i));
// ★ // smartIIC1.Write_Byte((byte)(iSlaveAddress + i));
// ★ // smartIIC1.Write_Byte((byte)(iMemAddress | i));
// ★ // smartIIC1.Write_Byte((byte)(iMemAddress + i));
// ★ yData[i] = smartIIC1.Read_Byte(SmartX.SmartIIC.ACKSIG.NOACK);
// ★ }
// 중지조건 신호를 발생시킵니다.
smartIIC1.Stop_Signal();
// 읽어온 데이터를 ListBox에 출력합니다.
m_strListItem[0] = iMemAddress.ToString();
m_strListItem[1] = iData.ToString();
// ★ m_strListItem[1] = Encoding.Default.GetString(yData, 0, 34);
lsbReadData.AddItem(m_strListItem);
의도대로 되지 않고, 전구간에서 쓰레기값(?)이라 할 수 있는 255만 표시되고 있습니다.
어떤 방법으로 진행해야 frame 단위로 읽어 들일 수 있을까요?