M95M02-DR 256KB EEPROM メモリ チップを MSP430 マイクロコントローラと接続しようとしています。サンプル テストとして、次の文字列を書き込もうとしました。
第一章 うさぎの穴を下る。アリスは、銀行で妹のそばに座っているのにうんざりし始めていました。
チップからデータを読み取ろうとすると、次のようになります。
第一章 うさぎの穴を下る。アリスは、ベッドの上で妹のそばに座っていることにとてもうんざりし始めていました?????
? はジャンク データです。問題は、文字列のサイズを数文字減らしても問題ありません。以前、SD カード上のファイルからデータを読み取り、256 バイト ブロックで EEPROM チップに書き込もうとしました。その場合は何も書かれていません。しかし、同じ操作をバイトごとに実行すると、問題はありませんでした。
これは私が使用しているコードです
static uint32_t i=0x025698;
static unsigned char message[120] = "CHAPTER I. Down the Rabbit-Hole."\
"Alice was beginning to get very tired of sitting by her sister on the bank, ";
static int size ;
unsigned char input[120];
size = strlen(message);
eeprom_spi_init();
eeprom_write( i ,message,size);
__delay_cycles(2500);
eeprom_read( i, input,size);
input[size]='\0';
ax_log_msg(E_LOG_INFO,input); //print command
低レベルの SPI 関数は次のとおりです。
void eeprom_write(uint32_t ui_addr, uint8_t *puc_wrData, uint8_t ui_dataLen)
{
uint8_t uac_wrBuf[260] = {0x00,};
uint8_t i = 0;
EEPROM_wrEnable();
uac_wrBuf[i++] = WRITE; /* Write Instruction */
uac_wrBuf[i++] = (uint8_t)((ui_addr >> 16) & 0xFF); /* First 8-bit MSB of 24-bit address */
uac_wrBuf[i++] = (uint8_t)((ui_addr >> 8) & 0xFF); /* Second 8-bit MSB of 24-bit address */
uac_wrBuf[i++] = (uint8_t)((ui_addr) & 0xFF); /* Third 8-bit MSB of 24-bit address */
while(ui_dataLen--) {
uac_wrBuf[i++] = *puc_wrData++;
}
uac_wrBuf[i++] = 0xFF;
EEPROM_ON();
EEPROM_sendFrame(uac_wrBuf, i);
EEPROM_OFF();
__delay_cycles(250000);
}
void eeprom_read(uint32_t ui_addr, uint8_t *puc_wrData, uint8_t ui_dataLen)
{
uint8_t uac_rdBuf[260] = {0x00,};
uint8_t uac_rdCmd[4];
uint8_t i = 0;
uac_rdCmd[i++] = READ;
uac_rdCmd[i++] = (uint8_t)((ui_addr >> 16) & 0xFF); /* First 8-bit MSB of 24-bit address */
uac_rdCmd[i++] = (uint8_t)((ui_addr >> 8) & 0xFF); /* Second 8-bit MSB of 24-bit address */
uac_rdCmd[i++] = (uint8_t)((ui_addr) & 0xFF); /* Third 8-bit MSB of 24-bit address */
EEPROM_ON();
EEPROM_sendFrame(uac_rdCmd, i);
EEPROM_readFrame(puc_wrData, ui_dataLen);
EEPROM_OFF();
}
EEPROM_sendFrame
とはEEPROM_readFrame
、SD カードにも使用しているので問題なく動作しています。
どんな助けでも大歓迎です。記載し忘れている情報がありましたら、お知らせください。追加します。
ありがとう