Save the below code as spidev_test.c on to your Raspberry Pi and compile it
gcc spidev_test.c -o spidev_test
Running
The MSP430 board LED1 will blink 3 times upon recognition of the SPI clock. After this initial sequence, when you SPI data “HELLO WORLD\n” to the MSP430 it will turn on the LED1 light.
On your Raspberry Pi run the previously compiled program. The -s options sets the frequency of the clock when performing the SPI communication.
sudo ./spidev_test -s 120000
Again, a successful sending of “HELLO WORLD\n” will be denoted by LED1 lighting up on the MSP430 board.
Hi! I found the blog looking for “cron” in the Raspberry. I was thinking about connecting one of my Launchpads to the Rasp and… THE NEXT POST WAS THIS! xD
Thanks for posting thi. You, Sir, made my morning.
octapod
Any way to daisy-chain multiple MSP430 Launchpads ?
Jack
What’s the advantage to connecting the RasPi and the Launchpad this way instead of over USB?
When I copy and paste the MSP430 script I get two errors:
Line 43: nop(); Error: function declared implicitly
Line 78: __attribute__((interrupt(USCIAB0RX_VECTOR))) void USCI0RX_ISR (void) Errors: expected a “{“, unnamed prototype parameters not allowed when body is present, expected a type specifier
I’m REALLY new to CCS and the MSP430. Could you clue me in to what I might be doing wrong?
It looks like the MSP430 code was built with GCC rather than CCS (despite the comment that says “Built with CCS Version 4.2.0”). The syntax used for interrupts and intrinsics varies between compilers.
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
And also replace nop() with _no_operation()
boku
On IAR you need to make the same changes but use __no_operation() instead of _no_operation(), there is a double underscore at the beginning as defined in the intrinsics.h file.
Just a quick note. Don’t go by the comments in the MSP430 code. MOSI is P1.2, and MISO is P1.1. It’s shown reverse of that in the comments. Cost me a couple of hours find out why I was receiving all 0xFF on the SPI slave. Excellent example. Now I can use MSP430 as DAC, and MCP3208 as an ADC for my project. Otherwise, I was thinking of using an Arduino.
Rick
Thanks for all the work it took to put this together. Followed all the steps and it ran perfectly the first time. Only thing I had any issue with was loading the api drivers. Never could get spidev to show up with lsmod. But I think the spi drivers are handled through raspi-config now. Anyway, now all I have to do is go back through code and understand exactly what’s going on here. I am long time C programmer but new to the MSP430 and SPI.
Mx
more than 500KHz clock speed its not working, i want to test with 8MHZ
Another note for those who may think they’re going crazy because the same configuration should work for UCSB0, It seems as though the clock phase is different. I changed the line:
UCB0CTL0 |= UCMSB + UCSYNC;
to
UCB0CTL0 |= UCMSB + UCSYNC + UCCKPH;
Alias
I have a question, how do you send the “Hello World” to the MSP430. Do you need a terminal like putty? Or is it possible to use the Arduino terminal? I’ve done everything, but I’m stuck at that part. I type in Raspbian terminal ./spidev_test, and it only prints the lines indicating the mode, the speed and the bits per word, but I have no idea what to do next.
Always excercise caution when working with electronics. All software is provided on an "as is" basis without warranty of any kind, express or implied. Unless otherwise noted, all code content is licensed under the Apache 2.0 license