We are trying to initialize SPI on STM32L476xG with STLink Nucleo L476RG.
I am checking the ‘SPI_SCLK’ signal through oscillopscope, but not getting any output. Could someone please help me with this? If am doing something wrong here?
Here is the code:
#include “mbed.h”
#include “LSM9DS1.h”
#include “mbed_power_mgmt.h”
const PinName spi_MOSI = PinName::PA_7;
const PinName spi_MISO = PinName::PA_6;
const PinName spi_CLK = PinName::PA_5;
const PinName spi_CS = PinName::PB_6;
SPI spi(spi_MOSI, spi_MISO, spi_CLK);
DigitalOut cs(spi_CS);
short spi_addr;
short spi_data;
int main()
{
//SPI config.
cs = 1;
spi.format(8,3);
spi.frequency(1000000); //1MHz
printf("SPI Master Initialized \r\n");
cs = 0; // The SCLK should be working when the chip select is low.
while(1) {
spi.write(0xFD);
}
cs = 1;
return 0;
}
Please could you let me know if am doing something wrong here? Or what could be the potential issues?
Thanks!
Regards,
Rohan