Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: STM32L452 SPI2 port assignation not working #28045
    Nezha
    Participant

      Hello Renzo,

      Thank you for your time. So I finally made it work. For some reason, it takes different tries to make the initialization happen.
      If I power cycle, I need to reset the board and unmount/remount the card so the initialization would work.

      All this to say this is working on a STM32L4 !

      You can check the issue I posted on SdFat github repo.
      https://github.com/greiman/SdFat/issues/447

      in reply to: STM32L452 SPI2 port assignation not working #27976
      Nezha
      Participant

        Hello Renzo,

        Thank you for your response! I actually tried your example but it did not work that’s why I posted in the forum. I don’t think I tried to start it twice. Here’s a code that I did for SPI1 port of my PCB and it works well.

        void setup() {
          Serial.begin(9600);
        
          ///////////////////////////////////////////////
          //        RADIO SETUP
          ///////////////////////////////////////////////
        
          SPIClass SPI_1(SPI1_MOSI, SPI1_MISO, SPI1_SCK);
          SPI_1.begin(SPI1_CS);
          // initialize SX1262 with default settings
        
          Serial.print(F("[SX1262] Initializing ... "));

        I also tried the QuickStart example and it worked by hardcoding the default SPI values.

        I did also change

        #define SPI_DRIVER_SELECT 1
        #define USE_SPI_ARRAY_TRANSFER 4

        And then -see attachment- I kind of also forced the default SPI pins to be SPI2 ports: (CS = PB2, MOSI = PC3, MISO = PC2, SCK = PB10)
        Where in the code could I hard code the pins it’s taking without compromising SPI1 port? Because I cannot just do it this way since I’m also using SPI1 for other purposes.

        For references you can see the second attachment that shows the output of the quickstart test which shows that the lib was able to connect with the SD CARD on SPI2.

        I wonder why would it work when I hardcode the SPI values, but not when I assign custom ones..

        I tried what you suggested and also this way to no luck:

        #define SD_CS_PIN PB2
          static SPIClass mySPI2(PC3, PC2, PB10);
          mySPI2.begin(SD_CS_PIN);
          #define SD2_CONFIG SdSpiConfig(SD_CS_PIN, USER_SPI_BEGIN, SD_SCK_MHZ(100), &mySPI2)
        
          if (!sd.begin(SD2_CONFIG)) {

        I wonder if the bug is on sd.begin() side.

        • This reply was modified 1 year, 1 month ago by Nezha.
        Attachments:
        You must be logged in to view attached files.
      Viewing 2 posts - 1 through 2 (of 2 total)