Report
3 months, 3 weeks ago.

Clash in libraries

Hi,

I am running the exact same code on the same dev board, a NUCLEO-STM32L053. In this code I am writing stuff out via SPI (PB6, PB5 and PB3) and also sampling a singla via the internal mcu ADC, on pin PC0.

The problem is that with one version of the code, I am running the latest version of the mbed.h libraries containing all Structs, Classes and Groups, and there the SPI does not work but the sampling does. Whilst with an earlier version, that only has the Classes in it, the SPI works but the ADC does not.

Could anyone please give me any suggestions on how to proceed?

/media/uploads/Osairiis/libraries.png

/media/uploads/Osairiis/main.cpp

Thanks !

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L053R8T6 microcontroller.

Code looks sane so it's time to get out the logic analyzer :( But before going that far, I had a problem when writing to SPI on a different chip and the fix was to add some delay between the chip select high/low and the SPI command. Here's a sample change....see if it makes any difference. If not then it's going to be more of a bit-level analysis to make sure you're fully meeting the Analog Devices timing/data requirements.

// SPI initialization
void spi_init()
{
    // Setup the SPI Setup: 16 bit data, mode 2, with 25MHz clock rate.
    // Note: mBed is MSB first SPI protocol
    AD9833_SPI.format(16, 2);
    AD9833_SPI.frequency(25000000);
    fSync = 1;
    wait_ms(20);
}

// SPI writing
void write_SPI(short dat)
{
    fSync = 0;
    wait_ms(20);
    AD9833_SPI.write(dat);
    wait_ms(20);
    fSync = 1;
}

Also, you don't need to add all those includes, just "mbed.h" is sufficient.

posted by Bill Bellis 04 May 2017
Comment on this question

1 Answer

3 months, 2 weeks ago.

Can you post up some code that you're having trouble with?

I apologise I had forgotten to attach them. Just did now. The code is the same in both cases, The difference is that in the case of "lib_1", the libraries are updated to the latest version and only the ADC works, and in the other case, only the SPI works.

posted by Jonathan Camilleri 04 May 2017

To post an answer, please log in.