Community
cancel
Showing results for 
Search instead for 
Did you mean: 
JYos
Novice
1,585 Views

What is proper way to shut down spi bus?

I am getting an error of "double free or corruption (fasttop): 0x085cf810" when I call the ~Spi() function. Is there something I am missing before calling the function or is there a better way to close the spi bus on the Edison Arduino board?

Any insight would be appreciated as I can't find any info on the issue.

8 Replies
Sergio_A_Intel
Employee
73 Views

Hi,

What image are you using? What code are you running? How are you stopping the function? Could provide more details about the testing conditions?

Sergio

JYos
Novice
73 Views

Hi, thanks for your reply. The image is 1.7.2 and I'm using C++. I am calling the ~Spi() deconstructor when the error arises. The spi is being used to send data to a single MAX7219 led display driver. Any insight would be helpful.

Sergio_A_Intel
Employee
73 Views

For C++ you could try to use MRAA, and you can close the connection with the command function mraa_spi_stop(). Let us know your results.

Sergio

Carlos_M_Intel
Employee
73 Views

Hi Bavaqua,

Do you have updates on this? Have you try with mraa_spi_stop() as Sergio suggested?

Regards,

Charlie

JYos
Novice
73 Views

Im sorry it has taken me so long to reply. I had been out of town this week.

I had tried to use the mraa_spi_stop() function directly with the same error result. In the mraa documentation the destructor ~Spi() calls the mraa_spi_stop() function, so it isnt any surprise. Both do stop the spi bus, however it throws the error and aborts which is strange.

Sergio_A_Intel
Employee
73 Views

Hi,

What code are you using? We'd like to try and replicate this issue. Can you post the code and steps you followed so far so we can reproduce this issue?

Sergio

JYos
Novice
73 Views

I'm using the arduino board with pins 13, 11, 10 configured for SPI via the linux commands. The board is connected to a MAX7219 LED dispaly driver via the SPI pins. (exluding pin12 MISO).

This is the class which calls the functions (Note: OO method is commented out as I have tried both methods):

MAX7219Driver::MAX7219Driver() {

/*

*

MAX7219Driver::s = new mraa::Spi(1);

MAX7219Driver::s->frequency(400000);

MAX7219Driver::s->bitPerWord(16);

MAX7219Driver::s->lsbmode(0);

*

*/

MAX7219Driver::s = mraa_spi_init(1);

mraa_spi_frequency(MAX7219Driver::s, 400000);

mraa_spi_bit_per_word(MAX7219Driver::s, 16);

mraa_spi_lsbmode(MAX7219Driver::s, 0);

}

MAX7219Driver::~MAX7219Driver() {

//MAX7219Driver::s->~Spi();

mraa_spi_stop(MAX7219Driver::s);

}

The main() processes data it receives from a hall sensor and, then writes data to the MAX7219, which all works the way it should. The problem occurs when a button is pressed which calls a function to send shut down command to the MAX7219 and, then exit the main() while(1) loop and call the SPI shutdown function, then exit program.

The program outputs the aforemetioned error and exits.

Sergio_A_Intel
Employee
73 Views

Hi,

Can you try to shut down the device after the SPI bus has been closed? Let me know your results.

Sergio

Reply