Jump to content


  • Content Count

  • Joined

  • Last visited

About wnorcott

  • Rank
    Noob Class

Recent Profile Visitors

222 profile views
  1. OK here is an update I seem to have got the thing working with SPI on USCA0 of the MSP430G2553. I just modified pins_energia.h and one file of the existing SPI library (usci_spi.cpp). By working I mean I can hook up my SD card module to the A0 channel and with this code I am successfully logging to the SD card using the (unmodified) pfatfs library. pins_energia.h I added a preprocessor flag #define SPI_USE_CHANNEL_A0 1 to remap the SPI pins constants // wnorcott 5/18/2015 // Uncomment the following ifdef to use USCI channel A0 instead // of B0 for SPI. That means you can use hardware SPI and I2C // simultaneously on the MSP430G2553 but you give up hardware // serial capability. The G2553 has two SPI channels A0 and B0. //#define SPI_USE_CHANNEL_A0 1 #define SPI_USE_CHANNEL_A0 1 #ifdef SPI_USE_CHANNEL_A0 static const uint8_t SS = 7; // P1.5 static const uint8_t SCK = 6; // P1.4 UCA0CLK static const uint8_t MOSI = 4; // P1.2 UCA0SIMO static const uint8_t MISO = 3; // P1.1 UCA0SOMI #else static const uint8_t SS = 8; /* P2.0 */ static const uint8_t SCK = 7; /* P1.5 */ static const uint8_t MOSI = 15; /* P1.7 */ static const uint8_t MISO = 14; /* P1.6 */ #endif changed SPI library module utility/usci_spi.cpp to test the new flag and variant the code to use channel A0: #ifdef SPI_USE_CHANNEL_A0 void spi_initialize(void) { UCA0CTL1 = UCSWRST | UCSSEL_2; // Put USCI in reset mode, source USCI clock from SMCLK UCA0CTL0 = SPI_MODE_0 | UCMSB | UCSYNC | UCMST; // Use SPI MODE 0 - CPOL=0 CPHA=0 pinMode_int(SCK, SPISCK_SET_MODE); pinMode_int(MOSI, SPIMOSI_SET_MODE); pinMode_int(MISO, SPIMISO_SET_MODE); UCA0BR0 = SPI_CLOCK_DIV() & 0xFF; // set initial speed to 4MHz UCA0BR1 = (SPI_CLOCK_DIV() >> 8 ) & 0xFF; UCA0CTL1 &= ~UCSWRST; // release USCI for operation } ... etc. in other words changed all the register references under the #ifdef to use USCI channel A0 hardware registers instead of channel B0. The methods I had to monkey with under the #ifdef were: spi_initialize, spi_disable, spi_send, spi_setdivisor, spi_set_bitorder, and spi_set_datamode. It would be nicer if it were possible (and maybe it is) to add the #define SPI_USE_CHANNEL_A0 1 in my own sketch or at least pass it as a -D flag to the compiler when I build the sketch, instead of having to define it in pins_energia.h Thanks again for your help.
  2. Thanks that confirms my doubts in that case I seemingly have to clone the pfatfs lib too since it includes SPI.h
  3. I notice that the usci_spi.cpp file for example hard codes references to channel B0 like register UCB0CTL1 and the like throughout.
  4. The MSP430G2553 has the UCSI hardware chip that supports UART, I2C and SPI. According to the user guide and a tutorial I read over on the Argenox Technologies web site (quote): The MSP430G2553 has two SPI interfaces, mapped with the following pins: UCA0 P1.1
  • Create New...