stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.81k stars 967 forks source link

SPI external eeprom suport #678

Closed mayurharge closed 5 years ago

mayurharge commented 5 years ago

hello @fpistm , I want to integrate SPI based external EEPROM with STM32F103C controller, The issue is the EEPROM is not responding to SPI.h library. I have tested the EEPROM on Arduino UNO using This Code

here they have used ATMEL specific instructions

//sample on leading edge of clk,system clock/4 rate (fastest)
  SPCR = (1<<SPE)|(1<<MSTR);
  clr=SPSR;
  clr=SPDR;

which are not supported on stm. Please suggest the solution for this. other details: Arduino IDE :- 1.8.0 STMCore: 1.7.0(latest).

regards, Mayur

fpistm commented 5 years ago

Hi @mayurharge your code is for UNO direct register access. I guess this example was made before API update. You have to create your own sketch using SPI API: https://www.arduino.cc/en/reference/SPI

Did you test some third party libraries, ex: https://github.com/regis44/spieeprom

mayurharge commented 5 years ago

Okay I will Try this

mayurharge commented 5 years ago

I have tried the library you suggested its behaving same. The error I am facing is I will get random values like 0,31(32-1),127(128-1),255(256-1) if i read a particular register I am attaching the .ino file I am using, please check. SPI_EEPROM.zip

fpistm commented 5 years ago

@mayurharge unfortunately, I'm not able to review all third party or user code and debug it. Your code seems to be a lot of copy/paste and try and use deprecated API. Please take time to make your code and try to debug it.

mayurharge commented 5 years ago

Sure

On Wed, 2 Oct, 2019, 7:55 PM Frederic Pillon, notifications@github.com wrote:

@mayurharge https://github.com/mayurharge unfortunately, I'm not able to review all third party or user code and debug it. Your code seems to be a lot of copy/paste and try and use deprecated API. Please take time to make your code and try to debug it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stm32duino/Arduino_Core_STM32/issues/678?email_source=notifications&email_token=AKDWW63U5RZJK2AHSUGVDOTQMSVNLA5CNFSM4I4V3AM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAE54WQ#issuecomment-537517658, or mute the thread https://github.com/notifications/unsubscribe-auth/AKDWW63EHAUWOXRIFRFDFXDQMSVNLANCNFSM4I4V3AMQ .

mayurharge commented 5 years ago

The issue is solved. There was problem with spi speed. After reducing the speed the communication was fine