Jump to content
Sign in to follow this  
mspdummy

MSP430F5529 - Using SPI modules other than default

Recommended Posts

Posted (edited)

What I'm trying to do:
We have been developing a project for school on a MSP430F5529 LaunchPad. We now want to move our project to a custom PCB for the final part. My partner has been using the UCB0 SPI module available through the LaunchPad to communicate to a sensor while I have been separately (as in a completely different sketch) using the same module to run the CC3100MODBOOST Boosterpack. Because no one on my team has much programming experience, we are using Energia to develop the project. We first tried to start with CCS, but we were in way over our heads.

Now that we have our different subsystems working, we are using an evaluation board to test out our circuit before going to a PCB. In order to run the SPI module and the sensor at the same time, I want to move the SPI communication with the CC3100 to the UCA1 SPI module.

I think I figured out to set up and access all of the pins through pins_energia.h. I created a new board for our setup and added it to Energia. I used some LEDs to check that I could access GPIO pins that weren't accessible on the LaunchPad, and they would all light up when I wanted them to. (I used the digitalWrite() function to check that I actually set up the pins_energia.h file correctly. I didn't directly send the pins high with "P1DIR |= BIT0; P1OUT |= BIT0;" style assignments.)

My next step was to switch communication with the CC3100 from UCB0 to UCA1 so my partner could keep using UCB0 for communication with his sensor. This is where I got really lost. I know that the code I have is using the SPI library included with Energia, but I don't know how to modify to do what I want it to do.

So my main question ultimately is: "How do I get the Energia sketch to use UCA1 instead of the default UCB0 SPI module for communication with the CC3100?"

Secondary to that, I am hesitant to change the installed libraries for Energia. Is there a way that I can reference copies of those libraries where my changes will be made?


What I've tried:
Looking through the code, I think that for the F5529, Energia is using the functions defined in utility/usci_spi.cpp. For this file at least, it seems to be hardcoded that the MSP will use UCB0. I tried to go through the file and replace every instance of "UCB0" with "UCA1", but that didn't work. I've also tried to look through some other posts about using alternate SPI ports on the F5529, but either I couldn't understand them or they didn't have solutions posted.


Hardware:
LaunchPad - MSP-EXP439F5529LP Rev 1.6
MCU - MSP430F5529IPN
Evaluation board - MSP-TSP430PN80USB
Boosterpack - CC3100MODBOOST Rev 1.0


Software
IDE - energia-1.8.7E21
OS - Windows 10 Pro


Other 43oh posts I've looked at (or at least the most relevant ones):
https://forum.43oh.com/topic/5844-f5529-using-alternate-spi-and-i2c-interfaces/
https://forum.43oh.com/topic/5174-getting-i2c1-ie-usci_b1-to-work-on-f5529-launchpad/


Thank you so much for y'alls help with this. I've been trying for a while now to get this on my own, but I keep hitting a wall. This is my first post here, so please let me know if I need to provide any additional info or if there was a different way I should have posed this question. Thank you!

 

Edit: typos/grammar

Edited by mspdummy
Typos and grammar

Share this post


Link to post
Share on other sites

Hi,

try the following commands.

SPI.setModule(1); // [0 for activating P1_5/6 for clk ; 1 for P3_5/6 ; 2 don't know yet]

SPI.begin();

Share this post


Link to post
Share on other sites

Nabil,

I tried that near the beginning, but I'm not sure if that will work. Looking at SPI.cpp, I think that the setModule() function will only have an impact if the MSP is using EUSCI SPI, but I think the F5529 is just using USCI.

Share this post


Link to post
Share on other sites

[Additional context: I'm testing all of this out with the basic ConnectWithWPA example provided with Energia]

So I've got a slight update on the project:

When I was messing around in utility/usci_spi.cpp earlier, I was editing a copy of the Library files in the same folder as the sketch and trying to reference those directly. I didn't end up working, so I got over my hesitation to mess with the install files and went straight into the AppData to edit the libraries there (I saved copies as backups).

In utility/usci_spi.cpp, I changed every instance of "UCB0" to "UCA1". Additionally, in my pins_energia.h file, I changed the MOSI, MISO, and SCK pins to the pins that UCA1 uses. I also changed the SPIMOSI_SET_MODE and SPIMISO_SET_MODE definitions to use the SPI ports. You can see these changes in the two files that I am uploading with this update.

I use GPIO pins and LEDs to let me know where I am in the code (I can't seem to get the Serial monitor to work over JTAG, but that's a whole different issue). The LEDs show that I am finally getting past the point where the CC3100 connects to the network (Line 73 will light up a LED), but the I'm not making it past the loop where it waits to obtain an IP address. If I go into the router logs, I can see where the CC3100 will connect to the network and an IP address will be assigned, but it looks like the module is immediately disconnecting from the network. Has anyone encountered this problem before?

TLDR: I can start the CC3100 and connect to the network, but I can't obtain an IP Address.

ConnectWithWPA.ino

usci_spi.cpp

pins_energia.h

Share this post


Link to post
Share on other sites

Updating in case anyone in the future has the same problem as me:


Finally figured out what my issue was. I had left some prints to Serial() in the sketch I was using. Apparently Serial() on the F5529 uses the same I/O pins I was using for my new SPI ports, so when Serial would use those pins it would mess with the WiFi module I had set up. The usci_spi and pins_energia files I had in my last post should work, provided you don't have any Serial prints. If you do, make sure to assign the Serial to other pins.

All in all, I think I chose my username well ^_^

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
Sign in to follow this  

×