SPI3 on STM32L432

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

poloppolop
Posts: 2
Joined: Wed Aug 02, 2017 3:00 pm

SPI3 on STM32L432

Postby poloppolop » Wed Aug 02, 2017 3:17 pm

Hello,

I have been trying to deal with an issue regarding the SPI3 on the Nucleo-L432KC. The project uses both SPI ports (1 & 3), spi1 works nicely. Some code snipets show what I am up to below.

Code: Select all

#define THERM_CS_PORT    GPIOA
#define THERM_CS_PAD     8
#define THERM_SPI_PORT  GPIOB
#define THERM_SCK_PAD   3
#define THERM_MOSI_PAD  5
#define THERM_MISO_PAD  4
#define SPI_BaudRatePrescaler_4         ((uint16_t)0x0008) //  21 MHz      10.5 MHz
////////////////////////

static SPIConfig spi_cfg_therm = {NULL,
                  THERM_CS_PORT,
                                        THERM_CS_PAD, SPI_CR1_CPOL | SPI_CR1_CPHA |
                                        SPI_BaudRatePrescaler_4,
                                        0
};

/////////////////////////

  palSetPadMode(THERM_SPI_PORT, THERM_SCK_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_SCK_PAD));
  palSetPadMode(THERM_SPI_PORT, THERM_MOSI_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_MOSI_PAD));
  palSetPadMode(THERM_SPI_PORT, THERM_MISO_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_MISO_PAD));
  palSetPadMode(THERM_CS_PORT, THERM_CS_PAD, PAL_MODE_OUTPUT_PUSHPULL);
 
  //////////////////////////
 
  spiStart(&SPID3, &spi_cfg_therm);
 
  //////////////////////////
 
        spiStart(&SPID3, &spi_cfg_therm);
      spiSelect(&SPID3);
      spiExchange(&SPID3, VOSPI_FRAME_SIZE, tx, lepton_frame_packet);
      spiUnselect(&SPID3);
      spiStop(&SPID3);


The above code is only snipets, though the other parts of my code should not matter. I intend to read from a FLIR lepton module and my example is heavily based on this one https://github.com/groupgets/LeptonModule/tree/master/software/STM32F3Discovery_ChibiOS

I get only rubbish out, mostly 0s though there are the occasional lumps of data. The PB3 pin is SPI3_SCK though I know there can be issues with clash with JTDO/SWO, though I think the above code should deal with that with the setting alternative modes. I have also checked the DBGMCU_CR register and it seems that TRACE_IOEN is cleared (which should mean that SWO is not active).

Any other ideas for me to check?

poloppolop
Posts: 2
Joined: Wed Aug 02, 2017 3:00 pm

Re: SPI3 on STM32L432

Postby poloppolop » Thu Aug 03, 2017 1:23 am

Hello,

Just a heads up, I solved the problem. Unfortunately it was one of those problems that was solved only after I started to lose grasp of reality. So I do not have much advice for the future. Though I will make sure that I post my repo here when it is workable for someone who finds themselves in a very similar situation. My username is je310 on git hub, just in case I don't make it back, the repo will be public when I get around to making it.

avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: SPI3 on STM32L432

Postby avrhack » Mon Aug 07, 2017 11:33 am

How are you using Chibi on the L432? Yes it's in the latest CMSIS but there's no definition for it in the HAL yet as far as I can see - only the L471, L475, L476 L485 and L486.

I'd like to use some of these newer ones like the L432, L433, L462 etc. but can't as they aren't defined in Chibi.....


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 18 guests