• 0
Mahdi

Communicating with 2 Pmods at the same time crashes SPI bus

Question

Hello,

I am using Arty board attached to 2 peripheral modules (PmodSD and PmodNAV) to write navigation data to SD card. To do so, I am combining the C example codes provided on Github for each module, and simplified it a bit which is attached.

My problem is that each one of the modules are working fine individually with their own code, as long as the other Pmod is not initialized in the C code, but when I am using them at the same time it destroys my output to terminal and writes zero to both terminal and SD card. I am suspicious that the issue is because PmodSD and PmodNAV are both using AXI_LITE_SPI to talk to Microblaze, and I do not have any control on SPI bus when I am writing data. As a result, Microblaze does not know how to communicate with both of Pmods at the same time. Does this make sense? What is the best way to control the AXI_LITE_SPI when there are multiple modules connected to the Microblaze? I am trying to keep this as simple as possible, so I can use the example codes. Any help is highly appreciated.

-Mahdi

main.cc

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @jpeyron,

Thanks for your response. I believe I have figured out where the issue is coming from. I was initializing both of PmodNAV and PmodSD inside the main function, and that was keeping the AXI_LITE_SPI busy all the time, so I was not able to use it 2 times in a row. This is how I fixed it. I put the PmodNAV code inside a separate .cc file and defined a function in there to return navigation data as an array. I did the same thing for SD card, where it was writing anything that I was passing to its function. Then in the main file, I called the PmodNAV first, and copied its output into an array and then I called the SD card function to write the same array to the card. Apparently, After calling a function in the main code, the AXI_LITE_SPI connection that is used inside that function would be free, so you are able to use it and initialize another Pmod. But when you initialize that module directly in the main code, AXI_LITE_SPI is still connected to Micrbolaze, so you are not allowed to use it for a 2nd connection. I am all set now.

-Mahdi

Share this post


Link to post
Share on other sites
  • 0

Thanks @jpeyron. Just to give you a heads up, if you are creating your SDK project in C++ which is what I did, don't forget to include these two statements at the beginning and at the end of PmodNAV.h header file, since there are some undefined reference issues between C and C++ functions for these example codes. 

Add this to top of PmodNAV.h

#ifdef __cplusplus
extern "C" {
#endif
 

and this to the end of it, and you would be fine.

#ifdef __cplusplus
}
#endif

 

Good luck,

-Mahdi

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now