Search the Community

Showing results for tags 'SPI'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Found 62 results

  1. Dear Engineers, Please help me send data to Arduino from my MSP430F5529 using SPI interface. I want to use SPI iterface because in future I want to use the modified code for Attiny13A instead of the Arduino Leonardo. Details are given below. Thank you for your support. Information to Provide When Asking for Help: Model of LaunchPad used and revision number : MSP430F5529 Launchpad Rev 1.6 & Arduino Leonardo Model of the MCU used : MSP430F5529 & ATMEGA32U4~AU at 15Mhz Name and version of the IDE used : Energia 1.6.10E18 & Ardduino IDE 1.8.2 OS the IDE is running on : Linux Mint 18 Whenever possible, minimal code to replicate the issue : Required from good developer
  2. (I started this [Energia Library] topic and copied my spiE library over to make it easier to find) I wanted to improve the compatibility of the SPI.h lm4f library to include functions of arduino user contributed SPI.h libraries. I found SPI2.h here: http://forum.stellar...two-spi-modules. This library added multi-module features but removed the 123 & 1294 compatibility. I have merged SPI2 and the core SPI libs into spiE.h and added several more function variations. spiE.h best features are: 1. Array transfer up to 255 bytes. This is 5x faster than single byte transfer. 2. SPI2's pinMode() and digitalWrire() functions are replaced with faster macros. 3. Support for __TM4C129XNCZAD__, __TM4C1294NCPDT__, BLIZZARD_RB1 (LM4F) boards 4. Up to 4 instances can be defined: SPI0, SPI1, SPI3, & SPI2 is instantiated by default as SPI for arduino code compatibility. 5. Multiple SlaveSelect pins can be used fir multiple devices on one data line. defaultSS, default +SS2, or SS1 + SS2, etc. I have tested this on the 129. If you have a need for it and can try it on the other boards before I upload it to github, be my guest.
  3. Nick Gammon published an interesting post on using SPI on 16 MHz Arduinos to run WS2812 LEDs (aka neopixels) at: He also provides a link with a lot of information about the NRZ protocol used by the WS2812 and tolerances: The tolerances are actually quite a bit looser than what I previously believed. So, I set out to do something similar with Energia and LaunchPads running at different speeds. Spoiler alert: It works. The previously linked articles provide all the background so minimal information is repeated here. NRZ is a one wire protocol that transfers information to the LEDs by varying the length of the signal when high. A longer pulse is used for a 1, and a shorter one for a 0. The timing, with tolerances, is shown in the figure below. The length between pulses cannot exceed about 5 us and most everything else is pretty loose. The protocol is implemented using SPI which I find pretty clever. A byte is sent out with the SPI module with the proper length to represent the desired bit for the protocol. The following must be determined and set to do this: Set proper SPI clock speed using SPI.setClockDivider() in Energia Determine the proper byte to send by SPI.transfer() in Energia to represent a 0 or 1 bit For example, using the MSP430F5529: Clock speed is 25.6 MHz Setting the SPI clock divider to 4 gives a SPI clock of 6.4 MHz and since the SPI block executes in one cycle (Arduino executes in 2), each bit in the byte is equivalent to 156.25 ns. Therefore, to send a pulse indicating a "1", a byte equal to 0b1111000 could be used which gives 4x156.25 = 625 ns. This is in the acceptable range of 550 to 850 ns. Similarly, for a 0 an acceptable byte would be 0b11000000 or 312.5 ns. A similar process can be used to determine acceptable values for the MSP430G2553. The sketch below is a simplification of the library presented by Nick which and includes the modifications described above to run on both the G2553 and F5529. The preprocessor is used to set appropriate values for the clock divider and long and short bytes. The functions are very nearly the same as posted by Nick. Note that interrupts must be disabled before sending data and then reenabled manually after. /* * WS2812 display using SPI on various TI LaunchPads with Energia * * Connections: * LaunchPad LED Strip * --------- --------- * 3V3 5VDC * Pin 15 (MOSI) DIN * GND GND * * How to use: * ledsetup (); - Get ready to send. * Call once at the beginning of the program. * sendPixel (r, g, ; - Send a single pixel to the string. * Call this once for each pixel in a frame. * Each colour is in the range 0 to 255. Turn off * interrupts before use and turn on after all pixels * have been programmed. * show (); - Latch the recently sent pixels onto the LEDs . * Call once per frame. * showColor (count, r, g, ; - Set the entire string of count Neopixels * to this one colour. Turn off interrupts before use * and remember to turn on afterwards. * * Derived from NeoPixel display library by Nick Gammon * * With ideas from: * * Released for public use under the Creative Commons Attribution 3.0 Australia License * * * F Milburn November 2016 * Tested with Energia V17 and WS2812 8 pixel strip on launchpads shown below. */ #include <SPI.h> #if defined(__MSP430G2553) #define SPIDIV SPI_CLOCK_DIV2 // 16 MHz/2 gives 125 ns for each on bit in byte #define SPILONG 0b11111100 // 750 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11100000 // 375 ns (acceptable "on" range 200 to 500 ns) #elif defined(__MSP430F5529) #define SPIDIV SPI_CLOCK_DIV4 // 25.6 MHz/4 gives 156.25 ns for each on bit in byte #define SPILONG 0b11110000 // 625 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11000000 // 312.5 ns (acceptable "on" range 200 to 500 ns) #else #error This microcontroller is not supported #endif const unsigned int PIXELS = 8; // Pixels in the strip void setup (){ ledsetup(); } void loop (){ // Show a solid color across the strip noInterrupts(); // no interrupts while sending data showColor (PIXELS, 0xBB, 0x22, 0x22); // single color on entire strip interrupts(); // interrupts are OK now delay(1000); // hold it for a second // Show a different color on every pixel noInterrupts(); // no interrupts while sending data sendPixel(0xBB, 0x00, 0x00); // red sendPixel(0x00, 0xBB, 0x00); // green sendPixel(0x00, 0x00, 0xBB); // blue sendPixel(0xBB, 0xBB, 0xBB); // white sendPixel(0xBB, 0x22, 0x22); // pinkish sendPixel(0x22, 0xBB, 0x22); // light green sendPixel(0x22, 0x22, 0xBB); // purplish blue sendPixel(0x00, 0x00, 0x00); // pixel off interrupts(); // interrupts are OK now delay(1000); // hold it for a second } // Sends one byte to the LED strip by SPI. void sendByte (unsigned char { for (unsigned char bit = 0; bit < 8; bit++){ if (b & 0x80) // is high-order bit set? SPI.transfer (SPILONG); // long on bit (~700 ns) defined for each clock speed else SPI.transfer (SPISHORT); // short on bit (~350 ns) defined for each clock speed b <<= 1; // shift next bit into high-order position } // end of for each bit } // end of sendByte // Set up SPI void ledsetup(){ SPI.begin (); SPI.setClockDivider (SPIDIV); // defined for each clock speed SPI.setBitOrder (MSBFIRST); SPI.setDataMode (SPI_MODE1); // MOSI normally low. show (); // in case MOSI went high, latch in whatever-we-sent sendPixel (0, 0, 0); // now change back to black show (); // and latch that } // end of ledsetup // Send a single pixel worth of information. Turn interrupts off while using. void sendPixel (unsigned char r, unsigned char g, unsigned char { sendByte (g); // NeoPixel wants colors in green-then-red-then-blue order sendByte (r); sendByte (; } // end of sendPixel // Wait long enough without sending any bits to allow the pixels to latch and // display the last sent frame void show(){ delayMicroseconds (9); } // end of show // Display a single color on the whole string. Turn interrupts off while using. void showColor (unsigned int count, unsigned char r , unsigned char g , unsigned char { noInterrupts (); for (unsigned int pixel = 0; pixel < count; pixel++) sendPixel (r, g, ; interrupts (); show (); // latch the colours } // end of showColor The timing, when checked on a logic analyzer, checks out with the calculations above (hooray for math). The "gaps" between pulses are within tolerance and largely set by code overhead as well as the byte being sent. And here it is showing the strip lit up in one color. I tried this on several other LaunchPads I had handy and here is a summary: FR6989 - I had never noticed, but Energia defaults to 8 MHz. Doing the math, there isn't a good match to the WS2812 requirements without changing processor speed (which I did not try). MSP432 - there was behavior I couldn't explain, probably due to RTOS and I didn't pursue this for long. In summary, the method works although I did limited experimentation. It would be even easier to implement outside of Energia with full access to clocks. It was an interesting exercise but alternative methods have been posted here on 43oh with tuned assembler and having used those successfully in the past, I will probably continue to preferentially use them in the future.
  4. Hi, I'm implementing an application for CC3200MOD in Energia 1.6.10E18 environment in which host MCU (Atmel AT76C114) sends jpeg image data (size varies from 1MB to 3MB) over SPI to CC3200MOD which then sends it over WiFi to PC. So Atmel acts as SPI master and CC3200MOD SPI slave. The bottleneck is SPI receive rate in CC3200MOD end. I need to configure host MCU SPI clock to 10.5MHz in order to receive correct data on CC3200MOD. With higher clock rate the data gets corrupted. When receiving valid data the transfer rate is 0.17 MBps. This is way too low for our purposes. I have understood that by using SPI DMA one could receive higher transfer rate. Are there any SPI DMA examples available for SPI slave receive in Energia environment? Does SPI DMA work on SPI slave when SPI master sends data continuously or does it require changes also for the sending procedure from SPI master? Thanks, Yuzzie
  5. I'm trying to use a cc1310 with a pressure sensor (BMP280) using the hardware port. I check at address 0xD0 for the chip ID (0x58) and this works but beyond this point there is no further SPI activity although I need to set up the filters and over-sampling etc. It's looking like I'll have to switch to CCS, but before I do, has anyone had this same problem and found a solution? BTW, this same sketch works fine with cc3200 (not emt) and the 430FR5969 which suggests a multi-tasking connection. Steve
  6. Hi, I am trying to read ADC channel values from MCP3911 using MSP launchpad using SPI protocol. When i used Arduino Mega the protocol is working fine. But when i use any TI devices i am having a problem, it always gives me all 0'S or 1's. I am using energia for MSP devices. Any i have chosen the appropriate pins as defined in the enegia pin layout. msp430----- static const uint8_t SS = 8; /* P2.7 */ static const uint8_t SCK = 7; /* P3.2 */ static const uint8_t MOSI = 15; /* P3.0 */ static const uint8_t MISO = 14; /* P3.1 */ Can someone help me troubleshoot where i am going wrong. Thanks in advance. // SPI Stuff here #include "SPI.h" const uint8_t MCP3911_CS = SS; // Teensy SPI CS1 = MCP3911 void setup() { //SPI Bus setup digitalWrite(MCP3911_CS,HIGH); // pinMode (MCP3911_CS, OUTPUT); // MCP3911 SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); SPI.setClockDivider(SPI_CLOCK_DIV8); //i.e. 6MHz on a Teensy running at 48MHz. SPI.begin(); //Setup Serial Comms Serial.begin(115200); Write_MCP3911_Register (0x0D, B11000010); } int32_t adc; void loop() { //adc = Read_MCP3911_24bit(0x00); Read_MCP3911_Register(0x0D); // Serial.print("Ch0 : "); // Serial.println(adc); delay(200); } uint8_t Write_MCP3911_Register (uint8_t MCP3911_Register_Address, uint8_t Command) { Serial.print("Command Register Received: "); Serial.print(MCP3911_Register_Address,HEX); Serial.print(" - Command Received: "); Serial.println(Command,BIN); MCP3911_Register_Address <<= 1; //left shift address one digit MCP3911_Register_Address &= B00111110; // and ensure last digit is a zero for write command digitalWrite(MCP3911_CS, LOW); // now take CS low to enable SPI device SPI.transfer(MCP3911_Register_Address); // send address with write command to MCP3911 SPI.transfer(Command); //now send payload digitalWrite(MCP3911_CS, HIGH); // deselect the CS pin. Serial.print(" Write Command Byte Sent: "); Serial.println(MCP3911_Register_Address,BIN); // verify what command was sent (i.e. address and write bit = 0) //Now Verify all went well. If so, have the function return value of one, //otherwise, alert the user that something is amiss. uint8_t Response = Read_MCP3911_Register (MCP3911_Register_Address>>1); if (Response == Command) return 1; else { Serial.println(""); Serial.print("Error for register: "); Serial.print(MCP3911_Register_Address>>1,BIN); Serial.print(" - Command Sent: "); Serial.print(Command,BIN); Serial.print(" - Response Received: "); Serial.println(Response,BIN); Serial.println(""); return 0; } } uint8_t Read_MCP3911_Register (uint8_t MCP3911_Register_Address) { MCP3911_Register_Address <<=1; //left shift address one bit for command byte MCP3911_Register_Address |=1; // Ensure read bit is set Serial.print(" Read Byte Command Sent: "); Serial.print(MCP3911_Register_Address,BIN); digitalWrite(MCP3911_CS, LOW); SPI.transfer(MCP3911_Register_Address); // send address with read command to MCP3911 uint8_t Response = SPI.transfer(0x00); digitalWrite(MCP3911_CS, HIGH); Serial.print(" - Response Received: "); Serial.println(Response,BIN); return Response; } void Reset_ADC() { // Puts ADC into Reset Mode, i.e. stops ADC conversions until setup is complete. Write_MCP3911_Register (0x0D, B11000010); } int32_t Read_MCP3911_24bit( uint8_t MCP3911_Register_Address) { uint8_t HB,MB,LB=0, MCP3911_CTRL=0;; int32_t adc0code=0; MCP3911_CTRL = 0; MCP3911_CTRL =(MCP3911_Register_Address<<1); //left shift address one digit for write command MCP3911_CTRL |= 1; //Turn on Read Operation by toggling last bit on digitalWrite(MCP3911_CS, LOW); SPI.transfer(MCP3911_CTRL); // send command byte to MCP3911 HB = SPI.transfer(0x0);//receive High Byte MB = SPI.transfer(0x0);//receive Middle Byte LB = SPI.transfer(0x0);//receive Low Byte digitalWrite(MCP3911_CS, HIGH); adc0code = HB; adc0code = adc0code<<8; adc0code |= MB; adc0code = adc0code<<8; adc0code |= LB; //connecting the 3 bytes to one number return adc0code;// returning result }
  7. Hello! Can anybody provide information about declaring multiple SPI objects for separate HW SPI modules or about the correct routine of switching the SPI channel of a SPI object? Im trying to an ILI9341 TFT and a XPT2043 touch controller, but sadly I can not join them to use a single bus, because the MISO of the TFT is killing the communication. Now i connected them to the same bus, MISO only going to the touch controller and it works fine, but the problem made me curious about the proper usage of the SPI modules.
  8. Hi Guys, I have been trying to interface CC2500 with my G2 launchpad, i am unable to do so. i interfaced cc2500 with the default spi configuration given in the SPI library with Energia. P2.0 - CS (active low) P1.5 - SCLK P1.6 - MISO aka SOMI P1.7 - MOSI aka SIMO P19- GD0 GDO2 pin is hanging i found a library which i used to code, the code initially checks the value in the registers of cc2500 and serially prints it and matches it with the default values. i have attached the thumbnails of serial output. when my CS pin is connected i get "o" output for all reisters and when i leave it open i get "FFFFFF" what can i do to correct that.. here is the code i used: #include <cc2500_REG.h> #include <cc2500_VAL.h> #include <SPI.h> #define CC2500_IDLE 0x36 // Exit RX / TX, turn #define CC2500_TX 0x35 // Enable TX. If in RX state, only enable TX if CCA passes #define CC2500_RX 0x34 // Enable RX. Perform calibration if enabled #define CC2500_FTX 0x3B // Flush the TX FIFO buffer. Only issue SFTX in IDLE or TXFIFO_UNDERFLOW states #define CC2500_FRX 0x3A // Flush the RX FIFO buffer. Only issue SFRX in IDLE or RXFIFO_OVERFLOW states #define CC2500_TXFIFO 0x3F #define CC2500_RXFIFO 0x3F #define No_of_Bytes 3 const int buttonPin = 5; // the number of the pushbutton pin int buttonState = 0; // variable for reading the pushbutton status const int GDO0_PIN = 19; // the number of the GDO0_PIN pin int GDO0_State = 0; // variable for reading the pushbutton status int led = 2; void setup() { Serial.begin(9600); pinMode(SS,OUTPUT); pinMode(led, OUTPUT); digitalWrite(led, HIGH); SPI.begin(); digitalWrite(SS,HIGH); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); pinMode(GDO0_PIN, INPUT); Serial.println("Starting.."); init_CC2500(); Read_Config_Regs(); } void loop() { Serial.println("Starting.."); //Read_Config_Regs(); /* // To start transmission buttonState = digitalRead(buttonPin); Serial.println(buttonState); while (!buttonState) { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); Serial.println("PB = 0"); } Serial.println("BP = 1"); */ RxData_RF(); /* while (buttonState) { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); Serial.println("PB = 1"); } */ } void RxData_RF(void) { int PacketLength; // RX: enable RX SendStrobe(CC2500_RX); GDO0_State = digitalRead(GDO0_PIN); // Serial.println("GDO0"); // Serial.println(GDO0_State); // Wait for GDO0 to be set -> sync received while (!GDO0_State) { // read the state of the GDO0_PIN value: GDO0_State = digitalRead(GDO0_PIN); //Serial.println("GD0 = 0"); delay(100); } // Wait for GDO0 to be cleared -> end of packet while (GDO0_State) { // read the state of the GDO0_PIN value: GDO0_State = digitalRead(GDO0_PIN); //Serial.println("GD0 = 1"); delay(100); } /* char rxbytes = ReadReg(0x3B); Serial.println("---------------------"); Serial.println("RX Bytes: "); Serial.println(rxbytes, HEX); Serial.println("---------------------"); */ char data1, data2; // Read length byte PacketLength = ReadReg(CC2500_RXFIFO); Serial.println("---------------------"); Serial.println(PacketLength,HEX); Serial.println(" Packet Received "); if(No_of_Bytes == PacketLength) { // Read data from RX FIFO and store in rxBuffer //for(int i = 1; i < PacketLength; i++) //{ data1 = ReadReg(CC2500_RXFIFO); Serial.println(data1,HEX); if(data1 = 0x09){ data2 = ReadReg(CC2500_RXFIFO); Serial.println(data2,HEX); if(data2 == 0x01 ){ //digitalWrite(led, LOW); } else{ //digitalWrite(led, HIGH); } } //Serial.println(ReadReg(CC2500_RXFIFO), HEX); //} Serial.println("---------------------"); } // Make sure that the radio is in IDLE state before flushing the FIFO // (Unless RXOFF_MODE has been changed, the radio should be in IDLE state at this point) SendStrobe(CC2500_IDLE); // Flush RX FIFO SendStrobe(CC2500_FRX); }// Rf RxPacket void WriteReg(char addr, char value) { digitalWrite(SS,LOW); while (digitalRead(MISO) == HIGH) { }; SPI.transfer(addr); delay(10); SPI.transfer(value); digitalWrite(SS,HIGH); } char ReadReg(char addr) { addr = addr + 0x80; digitalWrite(SS,LOW); while (digitalRead(MISO) == HIGH) { }; char x = SPI.transfer(addr); delay(10); char y = SPI.transfer(0); digitalWrite(SS,HIGH); return y; } char SendStrobe(char strobe) { digitalWrite(SS,LOW); while (digitalRead(MISO) == HIGH) { }; char result = SPI.transfer(strobe); digitalWrite(SS,HIGH); delay(10); return result; } void init_CC2500() { WriteReg(REG_IOCFG2,VAL_IOCFG2); WriteReg(REG_IOCFG1,VAL_IOCFG1); WriteReg(REG_IOCFG0,VAL_IOCFG0); WriteReg(REG_FIFOTHR,VAL_FIFOTHR); WriteReg(REG_SYNC1,VAL_SYNC1); WriteReg(REG_SYNC0,VAL_SYNC0); WriteReg(REG_PKTLEN,VAL_PKTLEN); WriteReg(REG_PKTCTRL1,VAL_PKTCTRL1); WriteReg(REG_PKTCTRL0,VAL_PKTCTRL0); WriteReg(REG_ADDR,VAL_ADDR); WriteReg(REG_CHANNR,VAL_CHANNR); WriteReg(REG_FSCTRL1,VAL_FSCTRL1); WriteReg(REG_FSCTRL0,VAL_FSCTRL0); WriteReg(REG_FREQ2,VAL_FREQ2); WriteReg(REG_FREQ1,VAL_FREQ1); WriteReg(REG_FREQ0,VAL_FREQ0); WriteReg(REG_MDMCFG4,VAL_MDMCFG4); WriteReg(REG_MDMCFG3,VAL_MDMCFG3); WriteReg(REG_MDMCFG2,VAL_MDMCFG2); WriteReg(REG_MDMCFG1,VAL_MDMCFG1); WriteReg(REG_MDMCFG0,VAL_MDMCFG0); WriteReg(REG_DEVIATN,VAL_DEVIATN); WriteReg(REG_MCSM2,VAL_MCSM2); WriteReg(REG_MCSM1,VAL_MCSM1); WriteReg(REG_MCSM0,VAL_MCSM0); WriteReg(REG_FOCCFG,VAL_FOCCFG); WriteReg(REG_BSCFG,VAL_BSCFG); WriteReg(REG_AGCCTRL2,VAL_AGCCTRL2); WriteReg(REG_AGCCTRL1,VAL_AGCCTRL1); WriteReg(REG_AGCCTRL0,VAL_AGCCTRL0); WriteReg(REG_WOREVT1,VAL_WOREVT1); WriteReg(REG_WOREVT0,VAL_WOREVT0); WriteReg(REG_WORCTRL,VAL_WORCTRL); WriteReg(REG_FREND1,VAL_FREND1); WriteReg(REG_FREND0,VAL_FREND0); WriteReg(REG_FSCAL3,VAL_FSCAL3); WriteReg(REG_FSCAL2,VAL_FSCAL2); WriteReg(REG_FSCAL1,VAL_FSCAL1); WriteReg(REG_FSCAL0,VAL_FSCAL0); WriteReg(REG_RCCTRL1,VAL_RCCTRL1); WriteReg(REG_RCCTRL0,VAL_RCCTRL0); WriteReg(REG_FSTEST,VAL_FSTEST); WriteReg(REG_PTEST,VAL_PTEST); WriteReg(REG_AGCTEST,VAL_AGCTEST); WriteReg(REG_TEST2,VAL_TEST2); WriteReg(REG_TEST1,VAL_TEST1); WriteReg(REG_TEST0,VAL_TEST0); /* WriteReg(REG_PARTNUM,VAL_PARTNUM); WriteReg(REG_VERSION,VAL_VERSION); WriteReg(REG_FREQEST,VAL_FREQEST); WriteReg(REG_LQI,VAL_LQI); WriteReg(REG_RSSI,VAL_RSSI); WriteReg(REG_MARCSTATE,VAL_MARCSTATE); WriteReg(REG_WORTIME1,VAL_WORTIME1); WriteReg(REG_WORTIME0,VAL_WORTIME0); WriteReg(REG_PKTSTATUS,VAL_PKTSTATUS); WriteReg(REG_VCO_VC_DAC,VAL_VCO_VC_DAC); WriteReg(REG_TXBYTES,VAL_TXBYTES); WriteReg(REG_RXBYTES,VAL_RXBYTES); WriteReg(REG_RCCTRL1_STATUS,VAL_RCCTRL1_STATUS); WriteReg(REG_RCCTRL0_STATUS,VAL_RCCTRL0_STATUS); */ } void Read_Config_Regs(void) { Serial.println("Configuration registers"); Serial.println(ReadReg(REG_IOCFG2),HEX); delay(1000); Serial.println(ReadReg(REG_IOCFG1),HEX); delay(1000); Serial.println(ReadReg(REG_IOCFG0),HEX); delay(1000); Serial.println(ReadReg(REG_FIFOTHR),HEX); delay(1000); Serial.println(ReadReg(REG_SYNC1),HEX); delay(1000); Serial.println(ReadReg(REG_SYNC0),HEX); delay(1000); Serial.println(ReadReg(REG_PKTLEN),HEX); delay(1000); Serial.println(ReadReg(REG_PKTCTRL1),HEX); delay(1000); Serial.println(ReadReg(REG_PKTCTRL0),HEX); delay(10); Serial.println(ReadReg(REG_ADDR),HEX); delay(10); Serial.println(ReadReg(REG_CHANNR),HEX); delay(10); Serial.println(ReadReg(REG_FSCTRL1),HEX); delay(10); Serial.println(ReadReg(REG_FSCTRL0),HEX); delay(10); Serial.println(ReadReg(REG_FREQ2),HEX); delay(10); Serial.println(ReadReg(REG_FREQ1),HEX); delay(10); Serial.println(ReadReg(REG_FREQ0),HEX); delay(10); Serial.println(ReadReg(REG_MDMCFG4),HEX); delay(10); Serial.println(ReadReg(REG_MDMCFG3),HEX); delay(10); Serial.println(ReadReg(REG_MDMCFG2),HEX); delay(10); Serial.println(ReadReg(REG_MDMCFG1),HEX); delay(10); Serial.println(ReadReg(REG_MDMCFG0),HEX); delay(10); Serial.println(ReadReg(REG_DEVIATN),HEX); delay(10); Serial.println(ReadReg(REG_MCSM2),HEX); delay(10); Serial.println(ReadReg(REG_MCSM1),HEX); delay(10); Serial.println(ReadReg(REG_MCSM0),HEX); delay(10); Serial.println(ReadReg(REG_FOCCFG),HEX); delay(10); Serial.println(ReadReg(REG_BSCFG),HEX); delay(10); Serial.println(ReadReg(REG_AGCCTRL2),HEX); delay(10); Serial.println(ReadReg(REG_AGCCTRL1),HEX); delay(10); Serial.println(ReadReg(REG_AGCCTRL0),HEX); delay(10); Serial.println(ReadReg(REG_WOREVT1),HEX); delay(10); Serial.println(ReadReg(REG_WOREVT0),HEX); delay(10); Serial.println(ReadReg(REG_WORCTRL),HEX); delay(10); Serial.println(ReadReg(REG_FREND1),HEX); delay(10); Serial.println(ReadReg(REG_FREND0),HEX); delay(10); Serial.println(ReadReg(REG_FSCAL3),HEX); delay(10); Serial.println(ReadReg(REG_FSCAL2),HEX); delay(10); Serial.println(ReadReg(REG_FSCAL1),HEX); delay(10); Serial.println(ReadReg(REG_FSCAL0),HEX); delay(10); Serial.println(ReadReg(REG_RCCTRL1),HEX); delay(10); Serial.println(ReadReg(REG_RCCTRL0),HEX); delay(10); Serial.println(ReadReg(REG_FSTEST),HEX); delay(10); Serial.println(ReadReg(REG_PTEST),HEX); delay(10); Serial.println(ReadReg(REG_AGCTEST),HEX); delay(10); Serial.println(ReadReg(REG_TEST2),HEX); delay(10); Serial.println(ReadReg(REG_TEST1),HEX); delay(10); Serial.println(ReadReg(REG_TEST0),HEX); delay(10); /* Serial.println(ReadReg(REG_PARTNUM),HEX); delay(1000); Serial.println(ReadReg(REG_VERSION),HEX); delay(1000); Serial.println(ReadReg(REG_FREQEST),HEX); delay(1000); Serial.println(ReadReg(REG_LQI),HEX); delay(1000); Serial.println(ReadReg(REG_RSSI),HEX); delay(1000); Serial.println(ReadReg(REG_MARCSTATE),HEX); delay(1000); Serial.println(ReadReg(REG_WORTIME1),HEX); delay(1000); Serial.println(ReadReg(REG_WORTIME0),HEX); delay(1000); Serial.println(ReadReg(REG_PKTSTATUS),HEX); delay(1000); Serial.println(ReadReg(REG_VCO_VC_DAC),HEX); delay(1000); Serial.println(ReadReg(REG_TXBYTES),HEX); delay(1000); Serial.println(ReadReg(REG_RXBYTES),HEX); delay(1000); Serial.println(ReadReg(REG_RCCTRL1_STATUS),HEX); delay(1000); Serial.println(ReadReg(REG_RCCTRL0_STATUS),HEX); delay(1000); */ }
  9. I try to use the Nokia 5110 with the card module tm4c1294 using a library I found this forum developed for tm4c123 but I can not display characters. I need help because they took several days on trying without success. I added the library you use, make some adjustments to the pins but not achievement communicate LCD screen. I added the library you use, make some adjustments to the pins but not achievement communicate LCD screen Examples.ino Graphics.c LCD_5110_SPI.cpp LCD_5110_SPI.h Terminal3.h Terminal6.h Terminal12.h
  10. Dear All, I would appreciate some help from you here. I am using Energia v0101E0014 (v15) The uploaded picture shown my 3200LP jumper setting. The 3200LP is using SPI to talk to Cypress CY5FRAMKIT ( The Cypress kit is using its default 5V setting on jumper J5. So I connect P3.1 (5V) to feed the Cypress power. My Wiring for cc3200 is as below CC3200 Signal Name ---- ------- P1.7 SCLK P2.3 CS P2.6 MOSI P2.7 MISO P2.1 GND P3.1 5V However I can't read/write data to it. I was able to use the same kit in Arduino platform, so the kit is good. Q1: DO I need to anything special to the CC3200 default jumper setting in order to use the above SPI pin iterface? Q2: What is the CS pin number in Energia code if I use P2.3 as the CS ping? Is it number "8", "18" or ... ? Thanks in advance.
  11. I'm trying to get my Tiva C (lm4f120) to read a adxl345 (accelerometer) and output the x, y and z values. I'm using the SSI2 peripheral, and everything seems to be wired correctly. By moving the adxl345 around, I can get the values to change, however they seem to overflow or something weird. They seem to tend toward 65535 when it should be reading 0. 65332 279 65519 65313 274 65528 65289 273 0 65271 275 1 65259 274 38 65318 238 69 65304 220 135 65303 207 134 65312 125 202 65308 67 242 65311 87 214 65316 69 222 65312 66 221 65310 68 219 65305 63 224 65513 65434 65430 58 68 65509 20 65518 3 33 21 33 11 65522 65532 18 65520 0 10 65527 65533 17 0 14 6 65528 65527 12 65525 2 19 65514 65532 22 65515 2 65526 65452 6 65368 65315 64 65353 65384 105 65379 65497 240 65340 84 270 65289 78 245 65234 70 205 65284 215 133 65277 228 107 65282 233 80 65297 184 67 65285 270 8 65281 274 65529 65281 273 65532 The code I'm using is below //Add the SPI library so we can communicate with the ADXL345 sensor #include <SPI.h> //Assign the Chip Select signal to pin 2. int CS = 2; //This is a list of some of the registers available on the ADXL345. //To learn more about these and the rest of the registers on the ADXL345, read the datasheet! char POWER_CTL = 0x2D; //Power Control Register char DATA_FORMAT = 0x31; char DATAX0 = 0x32; //X-Axis Data 0 char DATAX1 = 0x33; //X-Axis Data 1 char DATAY0 = 0x34; //Y-Axis Data 0 char DATAY1 = 0x35; //Y-Axis Data 1 char DATAZ0 = 0x36; //Z-Axis Data 0 char DATAZ1 = 0x37; //Z-Axis Data 1 //This buffer will hold values read from the ADXL345 registers. char values[10]; //These variables will be used to hold the x,y and z axis accelerometer values. long x,y,z; void setup(){ //Initiate an SPI communication instance. SPI.begin(); //Configure the SPI connection for the ADXL345. SPI.setDataMode(SPI_MODE3); //Create a serial connection to display the data on the terminal. Serial.begin(115200); Serial.println("GO!"); //Set up the Chip Select pin to be an output from the Arduino. pinMode(CS, OUTPUT); //Before communication starts, the Chip Select pin needs to be set high. digitalWrite(CS, HIGH); //Put the ADXL345 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register. writeRegister(DATA_FORMAT, 0x00); //Put the ADXL345 into Measurement Mode by writing 0x08 to the POWER_CTL register. writeRegister(POWER_CTL, 0x08); //Measurement mode } void loop(){ //Reading 6 bytes of data starting at register DATAX0 will retrieve the x,y and z acceleration values from the ADXL345. //The results of the read operation will get stored to the values[] buffer. readRegister(DATAX0, 6, values); //The ADXL345 gives 10-bit acceleration values, but they are stored as bytes (8-bits). To get the full value, two bytes must be combined for each axis. //The X value is stored in values[0] and values[1]. x = ((long)values[1]<<8)|(long)values[0]; //The Y value is stored in values[2] and values[3]. y = ((long)values[3]<<8)|(long)values[2]; //The Z value is stored in values[4] and values[5]. z = ((long)values[5]<<8)|(long)values[4]; //Print the results to the terminal. Serial.print(x); Serial.print('\t'); Serial.print(y); Serial.print('\t'); Serial.println(z); delay(100); } //This function will write a value to a register on the ADXL345. //Parameters: // char registerAddress - The register to write a value to // char value - The value to be written to the specified register. void writeRegister(char registerAddress, char value){ //Set Chip Select pin low to signal the beginning of an SPI packet. digitalWrite(CS, LOW); //Transfer the register address over SPI. SPI.transfer(registerAddress); //Transfer the desired register value over SPI. SPI.transfer(value); //Set the Chip Select pin high to signal the end of an SPI packet. digitalWrite(CS, HIGH); } //This function will read a certain number of registers starting from a specified address and store their values in a buffer. //Parameters: // char registerAddress - The register addresse to start the read sequence from. // int numBytes - The number of registers that should be read. // char * values - A pointer to a buffer where the results of the operation should be stored. void readRegister(char registerAddress, int numBytes, char * values){ //Since we're performing a read operation, the most significant bit of the register address should be set. char address = 0x80 | registerAddress; //If we're doing a multi-byte read, bit 6 needs to be set as well. if(numBytes > 1)address = address | 0x40; //Set the Chip select pin low to start an SPI packet. digitalWrite(CS, LOW); //Transfer the starting register address that needs to be read. SPI.transfer(address); //Continue to read registers until we've read the number specified, storing the results to the input buffer. for(int i=0; i<numBytes; i++){ values[i] = SPI.transfer(0x00); } //Set the Chips Select pin high to end the SPI packet. digitalWrite(CS, HIGH); } If someone is able to provide some guidance on how to test or fix this, that would be great. Thanks
  12. Hello, I am having trouble using a SPI DS3234 RTC with Energia and TivaC series launchpad. I am using the ds3234 library at which is originally written for arduino. I modified few settings in the initialization, tried few things, but have not had any luck. The module will not talk spi at all, and I get 1900.00.00 00:00:00 for date all the time. Here is the relevant code from the init section: void DS3234_init(const uint8_t pin, const uint8_t ctrl_reg) { pinMode(pin, OUTPUT); SPI.setModule(2); SPI.begin(); SPI.setClockDivider(SPI_CLOCK_DIV32); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE3); DS3234_set_creg(pin, ctrl_reg); delay(10); } First off I am setting spi port 2, before spi.begin. I tried all clock_dividers. The ds3234 supports upto 4mhz spi speed, so considering 80mhz clock speed for tivac board, I am using a div32 divider. I also scanned all of the dividers. I tried spi_mode 1 and 3 also. I also checked with an oscilloscope, that I am indeed talking with SPI2 port. (I can see the clock and cs lines with little spikes, when the tiva-c sends commands). For some reason the SPI port in the TivaC is unable to talk with this RTC chip. I could not figure out why. I tested the same code on a MSP430F5529 with the RTC connected to SPI0 port, and it worked as expected. Here is the relevant part for that one: (I only commented out the setModule statement, and used the div8 divider) void DS3234_init(const uint8_t pin, const uint8_t ctrl_reg) { pinMode(pin, OUTPUT); //SPI.setModule(2); SPI.begin(); SPI.setClockDivider(SPI_CLOCK_DIV8); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE3); DS3234_set_creg(pin, ctrl_reg); delay(10); } I also found a forum post at which complains about not being able to peek / poke the internal SRAM of the ds3234 - but unfortunately was not answer. I am speculating this too arises from similar SPI trouble. Any ideas/recomendations/help greatly appreciated, Best Regards, C.
  13. Here's a heads-up for anyone that wants to use the external SPI flash memory on the SensorTag: it's not accessible while a debugger session is active. Unfortunately the pin on the SensorTag's CC2650 which outputs the SPI clock to the flash memory is also used as the JTAG TDI pin: While you're debugging using the Debug DevPack the CC2650 is unable to clock data out to the flash chip. That means the flash will just sit there doing nothing and the CC2650 will end up reading zeroes from the SPI bus. To use the flash you need to be certain that no JTAG communication is occurring during execution of your firmware. The easiest way to do this is just to disconnect the Debug DevPack and power the SensorTag from a coin cell or external power supply. Alternatively you can use the Debug DevPack to power the SensorTag, but then you have to follow this procedure: Load your updated firmware onto the SensorTag using the Debug DevPack (I just run it in the CCS debugger) Terminate the debug session once you reach the start of main() Disconnect the Debug DevPack from USB Detach the SensorTag from the DevPack Connect the Debug DevPack to USB Reattach the SensorTag to the Debug DevPack Be careful not to miss step 2, or the DevPack will resume JTAG communication when everything is connected up again. I found that out the hard way... Also, the order of the last two steps is to avoid an issue with powering up the Debug DevPack while it's connected to a SensorTag with no coin cell. The advantage of that is that you don't need a coin cell (I've drained two already...) This makes testing code that uses the flash really difficult, as there's no way to use the debugger. I've been using a combination of UART logging, LED flashes and beep codes from the onboard buzzer to keep track of where the code is up to. The other thing I'm doing is detecting whether the flash is available during startup and skipping the flash accesses if it's not there. That lets the rest of the code run in the debugger without problems. The command sequence I'm using to detect the flash is: Repeatedly send a Read Status Register command (0x05, 0x00) until the received BUSY flag is clear Send a Read Mode Reset command (0xFF, 0xFF) Send a Release From Power Down command sequence (0xAB, 0x00, 0x00, 0x00, 0x00) Flash is available if the device ID value 0x12 is received in the last byte of the Release From Power Down sequence This sequence is arranged to work irrespective of the state of the flash chip. If JTAG is active the code will immediately fall through step 1 (BUSY flag is zero), but the received device ID at step 4 will be zero too. Step 2 covers against any remote chance that the device has ended up in dual-SPI mode. Step 3 wakes the chip if it has been put in suspend, and returns the device ID regardless.
  14. Hi, I'm trying to use an old stellaris launchpad board as a datalogger to an SD card for logging data from an accelerometer. I've already built such a project on the arduino hardware but best I can do is one reading per 2ms and I want to get it logging faster... at least 1 reading every 500us. So I thought I would port it onto the the launchpad boards I had kicking around. Straight up the SD card didn't work trying to use SPI(3) as the underlying SPI bus and I have downloaded and tried about 6 different sd card libraries but got nowhere. What I then did was go back to first principles. Confirm SPI is working on the default SPI bus SPI(2) before switching to SPI3 and before putting the SD libraries on top of it. So I grabbed the simplest SPI product I had, a microchip MCP4251 digital pot and wired it up on a breadboard and confirmed it fully working at 5v with the arduino. The MCP4251 is specced for 3.3v @10Mhz so presumably there should be no issue using it with the launchpad. When I wired it to the launchpad it didn't work. It sort of worked for one of the digital pot's channels but not for the other. It's sort of stuck on power up settings but the behaviour is not logical so I cannot diagnose a problem. I tried the clock divider to slow it down a bit to check if that was the case but to no effect. I tried setting the SPI modes to 0 and 1 as per the pots datasheet and I tried manually pulling down the CS earlier but it seems that the SPI library does something that disables access to the CS pin. Checking and comparing the signals at the chip with a scope they all "appear" correct but I only have a 2 channel scope and no logic analyser so I cannot check it with enough detail to confirm. I can bit bang it but want to do it in hardware. I swapped the pot for 2 others I have and they all perform (or don't perform) exactly the same. There's some sonsistency there at least. At this stage i'm left with wondering if there's an issue with the energia SPI library. Not something I would have expected to be the case as SPI is pretty basic functionality but you never know. Alternatively it's possibly an issue with using the library. Unfortunately there are no examples of SPI usage which are relevant as they all use the msp430. If anyone has an example that they can confirm working against a Microchip product It would be much appreciated. I'm using energia given i'm trying to port arduino code but happy to use CCS which i've used for other projects. I'm at work and don't have the code with me which is why I havent posted code. Regards, David
  15. Hello everyone, I am a newbie here, just received my MSP432 launchpad few days ago and I'm willing to develop a wireless bluetooth communication between my MSP432+Bluefruit LE SPI and my computer. I downloaded the librairies from Adafruit that are designed for Arduino and I think I succeeded to convert a honest part of the code for Energia. Though, I still have an important problem that stops me to go forward. Indeed the Bluefruit LE SPI dongle communicate through some commands called ATCommand, and I don't succeed to transmit those commands through the dongle. As an example this is the original Arduino code for a factory reset of the bluetooth device : /* Perform a factory reset to make sure everything is in a known state */ Serial.println(F("Performing a factory reset: ")); println("AT+FACTORYRESET"); bool isOK = ble.waitForOK(); // Bluefruit need 1 second to reboot delay(1000); // flush all left over ble.flush(); if ( ! isOK ){ error(F("Couldn't factory reset")); } In Arduino they use the println to transmit the command but in Energia I just get the "AT+FACTORYRESET" back in my Serial monitor but don't believe the device receives it. I tried to use SPI.transfer to send the message the following way but still get a failure result for the factory reset process : bool Adafruit_BLE::factoryReset(void) { char c; SPI.begin(); // println("AT+FACTORYRESET"); for (const char * p = "AT+FACTORYRESET" ; c = *p; p=p+2) { digitalWrite(18,LOW); SPI.transfer(0x10); // First Byte indicating that a COMMAND is sent according to Adafruit SDEP protocol SPI.transfer(c); // First byte of data const char * d = p+1; char e = *d; // Second byte of data SPI.transfer(e); digitalWrite(18,HIGH); } println("AT+FACTORYRESET"); bool isOK = waitForOK(); // Bluefruit need 1 second to reboot delay(1000); // flush all left over flush(); return isOK; } If anyone succeeded to connect this bluetooth dongle through SPI with MSP or has an idea of how to do it, pleeaase help me PS : It seems that this operation (like any other) is not achievable because the IRQ pin (This is the nRF51 -> Arduino 'interrupt' pin that lets the Arduino or MCU know when data is available on the nRF51, indicating that a new SPI transaction should be initiated by the Arduino/MCU) is never on HIGH. It is weird because normally after received any command message, it is supposed to turn on...
  16. As a part of my teaching work, I wanted to demonstrate connecting Raspberry Pi-2 (as SPI Master) to MSP430 LP with MSP430G2553 (as SPI Slave), as an alternative to Arduino-Uno as a SPI Slave. It was aimed at utilizing the ADC's of either of these micro-controller boards, as Raspberry Pi-2 does not have ADC modules. The working of Arduino Uno as the SPI Slave device was smooth and painless, but I spent many hours getting the MSP430G2553 working as a SPI SLave. Ultimately, I hit upon a hack (if there was one) and MSP430G2553 started working as SPI Slave! However, I do not understand why this hack works, or, why such a hack is needed at all. I shall appreciate any hints, help, explanations regarding this. I hope to be excused for this long posting. --------------- SPI Master code: helloArdu.c --------------------- /********************************************************** SPI_Hello_Arduino Configures an Raspberry Pi as an SPI master and demonstrates bidirectional communication with an Arduino Slave by repeatedly sending the text "Hello Arduino" and receiving a response ***********************************************************/ #include <sys/ioctl.h> #include <linux/spi/spidev.h> #include <fcntl.h> #include <cstring> #include <iostream> using namespace std; int fd; unsigned char hello[] = {'H','e','l','l','o',' ', 'A','r','d','u','i','n','o'}; unsigned char result; int spiTxRx(unsigned char txDat); int main (void){ fd = open("/dev/spidev0.0", O_RDWR); unsigned int speed = 1000000; ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); while (1){ for (int i = 0; i < sizeof(hello); i++) { result = spiTxRx(hello); cout << result; usleep (10); } } } int spiTxRx(unsigned char txDat){ unsigned char rxDat; struct spi_ioc_transfer spi; memset (&spi, 0, sizeof (spi)); spi.tx_buf = (unsigned long)&txDat; spi.rx_buf = (unsigned long)&rxDat; spi.len = 1; ioctl (fd, SPI_IOC_MESSAGE(1), &spi); return rxDat; } -------------------------------------------------------------------------- The Arduino Uno Slave code is: ---------------------- helloRaspi.ino -------------------------------- /************************************************************* SPI_Hello_Raspi Configures an ATMEGA as an SPI slave and demonstrates bidirectional communication with an Raspberry Pi SPI master by repeatedly sending the text "Hello Raspi" ****************************************************************/ unsigned char hello[] = {'H','e','l','l','o',' ', 'R','a','s','p','i','\n'}; byte marker = 0; void setup (void) { pinMode(MISO, OUTPUT); SPCR |= _BV(SPE); } void loop (void){ if((SPSR & (1 << SPIF)) != 0) { SPDR = hello[marker]; marker++; if(marker > sizeof(hello)){ marker = 0; } } } ------------------------------------------------------------------------- My Slave code for MSP430G2553 is: ------------------------- helloRaspi.c ------------------------------- #include "msp430g2553.h" #include <string.h> unsigned char cmdbuf[20]; char cmd_index=0; unsigned char hello[] = "Hello Raspi \n"; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= BIT0 + BIT6; while (!(P1IN & BIT5)); P1SEL = BIT5 + BIT6+ BIT7; P1SEL2 = BIT5 + BIT6 + BIT7; P2SEL = BIT0; P2SEL2 = BIT0; UCB0CTL1 = UCSWRST; // **Put state machine in reset** UCB0CTL0 |= UCCKPL + UCMSB + UCMODE_2 + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine* IE2 |= UCB0RXIE; // Enable USCI0 RX interrupt IE2 |= UCB0TXIE; __bis_SR_register(LPM4_bits + GIE); // Enter LPM4, enable interrupts } // end main() int index = 0; __attribute__((interrupt(USCIAB0TX_VECTOR))) void USCI0TX_ISR (void){ UCB0TXBUF = hello[index]<<1; // <---- Note this hack index++; if(index == 13) index = 0; } __attribute__((interrupt(USCIAB0RX_VECTOR))) void USCI0RX_ISR (void){ char value = UCB0RXBUF; if (cmd_index == 13) { if (strncmp(cmdbuf, "Hello Arduino", 13) == 0) { P1OUT |= BIT0; } else { P1OUT &= ~BIT0; } cmd_index = 0; } else { cmdbuf[cmd_index] = value; cmd_index++; } } ------------------------------------------------------------------------- Note the hack indicated by <---, where the character to be transmitted to back to RaspberryPi is shifted to left by one bit. Without this hack, which would be normal way, I found that, e,g, Character 'A' (0x41) sent was received as 0xA0, indicating that the character bits are being rotated to the right one place. With this hack, transmission was fine! Why this is so? Am I missing something or doing something wrong? Digging various discussion lists and forums, unfortunately, have not given any clue. There are plenty of example code for MSP430G2553 working in SPI Master mode, but few for Slave mode.
  17. Hello! I am having trouble getting the correct values from my MSP432 to my DAC. So basically my project setup is as follows: Transmitting: -Microphone connected to the A15 channel of my MSP432 -Xbee connected to the UART pins 3.2, 3.3 CODE Tx: const int MICAN = A15; // MIC in void setup() { Serial1.begin(9600); // baud rate setting } void loop() { Serial1.print(analogRead(MICAN));// send mic value over serial delay(100); // for testing } /////////////////////////////////////////////////////////////////////// Receiving: -MSP432 connected to my other Xbee device UART pins 3.2, 3.3 -MSP432 connected to LTC1658 14-bit DAC. -DAC is connected to pins 1.6 (MOSI, or input), 4.3 (CS), and 1.5 (SCLK) CODE Rx: const int slaveSelectPin = 6; // CS for the DAC #include <SPI.h> int DacVal = 0; // value to be sent to the dac void setup() { Serial1.begin(9600);//baud rate setting //spi crap pinMode (slaveSelectPin, OUTPUT); SPI.setClockDivider(SPI_CLOCK_DIV4); SPI.begin(); } void loop() { if (Serial1.available()>0) {// If there is SHIT in the buffer DacVal =; } //YOUR POST PROCESING HERE!!!!!!! DACWrite(DacVal); } void DACWrite(int Val) { char LSBs; char MSBs; // take the SS pin low to select the chip: //Split the int to 2 chars, the bit shift may be off, but i dont have any hardware to test on LSBs=char(Val); MSBs=char(Val>>8); digitalWrite(slaveSelectPin,LOW); // send in the address and value via SPI 1 byte at a time: SPI.transfer(LSBs); SPI.transfer(MSBs); // take the SS pin high to de-select the chip: digitalWrite(slaveSelectPin,HIGH); } ////////////////////////////////////// And basically I am not getting values that are correct when I put a oscilloscope on the output of the DAC. I am thinking my problem is somewhere in the Rx code because when my Tx board is setup I am reading the values from my other zigbee through the computer successfully. Any help would be great, thank you!!
  18. Hello everyone, I'm basically trying to port over Arduino's SD card library (which utilizes SPI communication) to Energia, and am starting by testing whether I am able to properly initialize the SD card or not. First, I made sure that the Arduino library worked on an AT Mega 2560 and SD card that I have (it did). I then moved on to porting the library for Energia. I changed the pin mapping and the SPI settings to work for the F5529 and so far I can prove with a logic analyzer that the SD initialization function commands the CS, SCLK, MISO, and MOSI SPI lines in the exact same manner for the MSP430 as for the Atmel, byte for byte. Basically, the information coming in to and out of each mircrocontroller is exactly the same so I know that all the SD card information is there for me However, the problem is that the information does not seems to be received by the MSP430 in the same manner as the Atmel and causes the initialization to fail. I think the roots of this issue involve differences between the way the Atmel device
  19. Hi, I'm a bit new to this... I'm wanting to improve the performance of the SPI, I understand that using DMA is the best solution. Are their any example of SPI with DMA? Currently without DMA, I have the SPI setup to send 1 byte at a time with: SPI_transmitData(LCD_EUSCI_MODULE, data); What I want to do is change this so I can fill a buffer with bytes, then say Send. Once thats finished sending I want to fill the buffer again and send the next set of bytes. I tried to use this code although it appears to hang at the last line! DMA_enableModule(); DMA_setControlBase(m_controlTable); DMA_assignChannel(DMA_CH0_EUSCIB0TX0); DMA_disableChannelAttribute(DMA_CH0_EUSCIB0TX0, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); DMA_setChannelControl(UDMA_PRI_SELECT | DMA_CH0_EUSCIB0TX0, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_8 | UDMA_ARB_8); DMA_setChannelTransfer(UDMA_PRI_SELECT | DMA_CH0_EUSCIB0TX0, UDMA_MODE_BASIC, m_data_array, (void*)SPI_getTransmitBufferAddressForDMA(EUSCI_B0_MODULE), 1024); DMA_assignInterrupt(DMA_INT1, 0); Interrupt_enableInterrupt(INT_DMA_INT1); ? I was planning to use the code above by filling the buffer "m_data_array" then calling DMA_enableChannel(0); although this didn't work. How do i know when the buffer has been transmitted?
  20. I have a Dig Pot the TPL0501 by Texas Instruments that I am trying to control with a micro controller. Link Here: I have been able to successfully control this with my CC3200 and the output signals look like Photo 1 attatched. I have since decided I want to do this with my MSP432 but I am not able to get it to work. The same code should work for each I assume. The output signals I am getting for the MSP432 are shown in photo 2. I have tried changing the mode but nothing seems to help. Any ideas? My code is listed below: #include <SPI.h> const int SS = 18; uint8_t value = 150; void setup() { pinMode(SS, OUTPUT); SPI.begin(); digitalWrite(SS, HIGH); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE3); SPI.setClockDivider(SPI_CLOCK_DIV32); } void loop() { digitalPotWrite(value); delay(100); } int digitalPotWrite(int x) { digitalWrite(SS, LOW); SPI.transfer(x); digitalWrite(SS, HIGH); }
  21. Hello all, I'm having trouble getting my digital pot to respond to the CC3200. Could someone please take a look at my code and let me know where I'm going wrong? Thanks. DataSheet for the digital pot; #include <SPI.h> const int SS = 8; uint8_t value; int volts = 0; void setup() { Serial.begin(9600); pinMode(SS, OUTPUT); SPI.begin(); delay(100); } void loop() { for(value = 0; value < 256; value += 20) { digitalWrite(SS, LOW); delay(10); SPI.transfer(value); delay(10); digitalWrite(SS, HIGH); delay(100); } }
  22. Here is some code to drive ws281x strips using DMA driven SPI for the msp430f5529. I hadn't seen any example code showing how to use DMA and SPI. The example also provides some code that shows how to use inline asm that will work with both msp430-gcc and msp430-elf-gcc. The code below was tested with a ws2811 strip and msp430-elf-gcc. -rick
  23. Hi, I'm struggling to get the the ILI9341 display to work on a MSP432. I've used it on an arduino with this display driver, so I figured that would be a good start for the porting. This display is setup to use SPI (SCK,MISO,MOSI, CS,DC). I understand this is called 4 wire SPI? The following is the code used to init the SPI is this correct? GPIO_setAsOutputPin(LCD_RESET_PORT, LCD_RESET_PIN); GPIO_setOutputLowOnPin(LCD_RESET_PORT, LCD_RESET_PIN); GPIO_setAsOutputPin(LCD_DC_PORT, LCD_DC_PIN); GPIO_setOutputLowOnPin(LCD_DC_PORT, LCD_DC_PIN); GPIO_setAsOutputPin(LCD_SPI_CS_PORT, LCD_SPI_CS_PIN); GPIO_setOutputLowOnPin(LCD_SPI_CS_PORT, LCD_SPI_CS_PIN); // // Configure SPI peripheral. // GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_MOSI_PORT, LCD_SPI_MOSI_PIN, LCD_SPI_MOSI_PIN_FUNCTION); GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_MISO_PORT, LCD_SPI_MISO_PIN, LCD_SPI_MISO_PIN_FUNCTION); GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_CLK_PORT, LCD_SPI_CLK_PIN, LCD_SPI_CLK_PIN_FUNCTION); eUSCI_SPI_MasterConfig spiMasterConfig = { EUSCI_B_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source CS_getSMCLK(), // Get SMCLK frequency 15000000, // SPICLK = 15 MHz EUSCI_B_SPI_MSB_FIRST, // MSB First EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, // Phase EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW, // Low polarity EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH // SPI Mode }; //EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH //EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW SPI_initMaster(LCD_EUSCI_MODULE, &spiMasterConfig); SPI_enableModule(LCD_EUSCI_MODULE); SPI_clearInterruptFlag(LCD_EUSCI_MODULE, EUSCI_B_SPI_RECEIVE_INTERRUPT); The code i'm unsure about is: - GPIO_setAsPeripheralModuleFunctionOutputPin Should SCK, MOSI, MISO all be set as output or input? - EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW Not really sure what this means is it correct? - EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT Not really sure what this means is it correct? -EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH Not really sure what this means is it correct? - SPI_clearInterruptFlag(LCD_EUSCI_MODULE, EUSCI_B_SPI_RECEIVE_INTERRUPT); I'm not using interrupts should I remove this line? Board: MSP432 Launchpad Datasheet:
  24. Hello everyone! Just wanted to say thank you for all the support and guidance everyone in this forum has towards beginners, you guys have been of so much help!! Now, here is a question: I am trying to interface 2 microcontrollers, a MSP430F5529 with a C2000 F28335 I was told the MSP doesnt support CAN, I would have to convert SPI to CAN and go from there. What do you guys suggest? I have never successfully used communication protocols. Any good examples of send and receive out there? Thanks in advance!
  25. Hi, I have connected two ADS1220 AD converters to LaunchPad MSP430F5529LP. First of all I needed to Chip select pins to manage the SPI communication so I updated some pin mapping. I also debugged that CS pins are working following my code. However I haven