PSoC5LP内のEEPROM制御について

Tip / ログイン to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
TeMa_2997106
Level 6
Level 6
Distributor - TED (Japan)
10 likes received 10 solutions authored 250 replies posted

PSoC5LP内にあるEEPROMに対して、16Byte未満の複数ByteをNon-Blockingで一括書込みしたいと考えています。

指定位置のデータを変更した後、EEPROM_StartWrite()を呼べば実現できると考えていますが正しいでしょうか。

※この関数がBlocking呼び出しなのかNon-Blocking呼び出しなのかがわかりませんでした。

もし、Non-Blockingではない、もしくは一括で書き込みできない場合は、

どのように処理すればよいでしょうか。

宜しくお願いします。

0 件の賞賛
1 解決策
AikoO_51
Moderator
Moderator
Moderator
100 sign-ins First question asked 50 solutions authored

結論から言うと、16 Byte未満の複数Byteの書き込みが可能で、且つブロッキングコードでないAPIはありません。

まずEEPROM_StartWrite API についてですが、EEPROMコンポーネントで自動生成されるEEPROM.cファイル内にAPIの説明について下記の記載があります。

*  This function does not block. The function returns once the SPC has begun

*  writing the data. This function must be used in combination with

*  EEPROM_1_Query(). EEPROM_1_Query() must be called

*  until it returns a status other than CYRET_STARTED. That indicates that the

*  write has completed. Until EEPROM_1_Query() detects that

*  the write is complete, the SPC is marked as locked to prevent another

*  SPC operation from being performed.

*  Starts a write of a row (16 bytes) of data to the EEPROM.

APIの処理内容でもブロッキングコードにはなっていないのですが,16 Byte固定での書き込みになります。

 

PSoC CreatorにあるPSoC5LPEEPROMサンプルコードで使用されているEEPROM_WriteByteAPIは、Byteごとに書き込みを行うのですが、処理が終わるまでブロックされます。

ですので、どのような処理を希望するかによりますが、Non-Blockを諦めてEEPROM_WriteByte を使用し、16 Byte 未満の希望のByte数のdataを書き込むという選択や、EEPROM_StartWrite APIを使用して16 Byteに満たない分のByte数を補うcodeを作成するなどの工夫が必要になります。

以上の点を考慮して、どのような処理にするかご検討ください。

Aiko Ohtaka
Infineon Technologies

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
MiNe_85951
Level 7
Level 7
Distributor - TED (Japan)
50 likes received 500 replies posted 50 solutions authored

EEPROMコンポーネントで自動生成されるEEPROM.cファイル内に

EEPROM_StartWrite APIの説明について下記の記載があります。

*  This function does not block. The function returns once the SPC has begun

*  writing the data. This function must be used in combination with

*  EEPROM_1_Query(). EEPROM_1_Query() must be called

*  until it returns a status other than CYRET_STARTED. That indicates that the

*  write has completed. Until EEPROM_1_Query() detects that

*  the write is complete, the SPC is marked as locked to prevent another

*  SPC operation from being performed.

APIの処理内容みてもブロッキングコードにはなっていないので、

EEPROMへ書き込む際は他の処理を行わないように、

割り込みを無効にするか、クリティカルセクションとして保護する必要があると思います。

EEPROM_StartWriteのAPIを使用したことは無いのですが、

説明に(ROW)書き込みを行うと記載があるため、

*  Starts a write of a row (16 bytes) of data to the EEPROM.

Byte書き込みを行うのであればEEPROM_WriteByteのAPIを使用した方が良いような気がしています。

EEPROM_WriteByteのAPIならば処理が終わるまでブロックされると記載されていますし、

配列で変数を用意し、forループで連続的に書き込むなどの使用法は過去に行ったことはあります。

PSoC CreatorにあるPSoC5LPのEEPROMサンプルコードではこちらのEEPROM_WriteByteのAPIが使用されていますので、

そちらを参照して頂いても良いかもしれません。

0 件の賞賛
TeMa_2997106
Level 6
Level 6
Distributor - TED (Japan)
10 likes received 10 solutions authored 250 replies posted

ありがとうございます。

行いたいのはNon-Blocking呼び出しですので、EEPROM_StartWrite() 自体は使えそうですが、

Byte単位での書き込みはEEPROM_WriteByte()の方がよいと思いますので、

他処理を含めてどちらがよいかは総合的に判断したいと思います。

0 件の賞賛
AikoO_51
Moderator
Moderator
Moderator
100 sign-ins First question asked 50 solutions authored

結論から言うと、16 Byte未満の複数Byteの書き込みが可能で、且つブロッキングコードでないAPIはありません。

まずEEPROM_StartWrite API についてですが、EEPROMコンポーネントで自動生成されるEEPROM.cファイル内にAPIの説明について下記の記載があります。

*  This function does not block. The function returns once the SPC has begun

*  writing the data. This function must be used in combination with

*  EEPROM_1_Query(). EEPROM_1_Query() must be called

*  until it returns a status other than CYRET_STARTED. That indicates that the

*  write has completed. Until EEPROM_1_Query() detects that

*  the write is complete, the SPC is marked as locked to prevent another

*  SPC operation from being performed.

*  Starts a write of a row (16 bytes) of data to the EEPROM.

APIの処理内容でもブロッキングコードにはなっていないのですが,16 Byte固定での書き込みになります。

 

PSoC CreatorにあるPSoC5LPEEPROMサンプルコードで使用されているEEPROM_WriteByteAPIは、Byteごとに書き込みを行うのですが、処理が終わるまでブロックされます。

ですので、どのような処理を希望するかによりますが、Non-Blockを諦めてEEPROM_WriteByte を使用し、16 Byte 未満の希望のByte数のdataを書き込むという選択や、EEPROM_StartWrite APIを使用して16 Byteに満たない分のByte数を補うcodeを作成するなどの工夫が必要になります。

以上の点を考慮して、どのような処理にするかご検討ください。

Aiko Ohtaka
Infineon Technologies
0 件の賞賛
TeMa_2997106
Level 6
Level 6
Distributor - TED (Japan)
10 likes received 10 solutions authored 250 replies posted

ご回答ありがとうございます。

Non-Blockingを前提とすると、後者のように足りないデータ分をダミー等で埋めるのが実現は簡単そうですので、

その方向で進めたいと思います。

以上です。

0 件の賞賛