Jump to content

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.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 73 results

  1. Aditee

    MSP430G2553 SPI with ADC

    Hi, I am completely new to serial communication. I wish to use a high speed ADC from TI ADS 8361. I want to interface with msp430g2553 using energia IDE. Can I get some code to check the ADC functions.
  2. I'm trying to use the UCA0 for SPI on MSP430FR2433 by using the SPI.setmodule(10); before SPI.begin(), but I'm not getting any data on the SPI lines. The default SPI on this launchpad is UCA1 and it works. After the above thing didn't work, I tried changing the core files: /home/username/.energia15/packages/energia/hardware/msp430/1.0.5/variants/MSP-EXP430FR2433LP/pins_energia.h In this file I changed: (from line 47 to 50) static const uint8_t SS11 = 8; /* P2.1 */ static const uint8_t SCK11 = 7; /* P2.3 */ static const uint8_t MOSI11 = 15; /* P2.4 aka SIMO */ static const uint8_t MISO11 = 14; /* P2.5 aka SOMI */ to: static const uint8_t SS11 = 8; /* P2.1 */ static const uint8_t SCK11 = 5; //P1_6 static const uint8_t MOSI11 = 4; //P1_4 aka SIMO static const uint8_t MISO11 = 3; //P1_5 aka SOMI And changed: #define DEFAULT_SPI 11 to: #define DEFAULT_SPI 10 But this also didn't work.pins_energia.h I have attached the changed file.
  3. Simple demo code that uses FR5969 Launchpad to set an AD5160 10k digital potentiometer in 1k increments. Device communication via SPI and control with a serial terminal program. Implemented with registers and interrupts. Link to github repo: https://github.com/microphonon/AD5160
  4. I am using this code to communicate to the Nokia 5110 LCD display: https://gist.github.com/DmitryMyadzelets/83b6e1384a1ee35a7f5f Looking at the waveforms on an oscilloscope, I saw that there are only 2 to 3 clock cycles per write. For instance, the attached screenshot is when I write 0x44. The top waveform is the clock, the middle is chip select, and the bottom is MOSI. That doesn't seem correct at all. Shouldn't there be 8 clock cycles for transmitting 8 bits?
  5. Hi all, I am trying to connect SPI flash (W25Q80DVSSIG-NDhttp://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/166/w25q80dv_5F00_revf_5F00_02112015.pdf) to MSP430g2553 launch pad. Here I made the connections as below P1.1 SOMI <---------- 2nd Pin DO P1.2 SIMO ----------->5th Pin DI P1.4 SCLK ----------->6th Pin CLK P2.0 SS ------------>1st Pin CS I tried to use example code from TI to get the manufacturer id and device id. But I am failing to receive the expected data. Please have a look into my code and tell me if I made any mistakes. Please find the attachment for my code and the data sheet of Winbond W25Q80DV spi flash memory. And if anyone have sample codes or driver codes please do share with me. Thanks in Advance. Regards Santhosh main - Copy.pdf w25q80dv_revf_02112015.pdf
  6. Hi All First, I would like to thank @Rei Vilo for providing the Library for the Kentec (BOOSTXL-k350qvg) library with Energia. I copied the code out of https://www.youtube.com/watch?v=XyeUpk6P4kA (as I didn't find the powerpoint or pdf) and got it to work with an MSP430F5529 launchpad. (Energia 18, Windows as the Mac version doesn't work atm). Then I compiled the same code on a MSP432P401R launchpad and it runs a lot slower than on the F5529 (I assume this is a known issue, due to slow SPI speed ( https://github.com/energia/msp432-core/issues/27 ) but also doesn't look the same, the fonts are "skinnier on the MSP432. This discrepancy, I cannot explain. Another question: If I want to write a changing variable, in this case simply the x-coordinate of the touch to the screen, how do I locally clear the screen without redrawing everything (or if I want to make a bar graph that represents eg a changing value of a sensor? Do I always draw a black rectangle, then the bar/text etc? or is there a simpler way that is not immediately obvious to me now? Next step: I have to learn more about state machines to switch screens (settings), do stuff there, come back to main without the program getting into badly readable territory. Thank you very much for your help. //First steps with the Kentec Display #include "SPI.h" #include "Screen_K35_SPI.h" Screen_K35_SPI myScreen; uint16_t colours[6]; uint16_t x; uint16_t y; uint16_t z; uint8_t initFlag; void setup() { Serial.begin(9600); Serial.println(); Serial.println("hello"); Serial.println(); pinMode(RED_LED, OUTPUT); myScreen.begin(); myScreen.clear(); colours[0] = myScreen.calculateColour(255, 0, 0); colours[1] = myScreen.calculateColour(0, 255, 0); colours[2] = myScreen.calculateColour(0, 0, 255); colours[3] = myScreen.calculateColour(255, 255, 255); colours[4] = myScreen.calculateColour(255, 255, 0); colours[5] = myScreen.calculateColour(0, 0, 0); x = 0; y = 0; z = 0; myScreen.setPenSolid(true); myScreen.setFontSolid(false); myScreen.setFontSize(2); initFlag = 1; } void loop() { if (initFlag) { drawHomeScreen(); initFlag = 0; } if (myScreen.isTouch() > 0) { myScreen.getTouch(x, y, z); myScreen.gText(10, 10, btoa(x, 8), colours[3]); Serial.print(x); Serial.print(" "); Serial.print(y); Serial.print(" "); Serial.println(z); } if (z > 100) { if ((x < 160 && x > 0) && (y < 240 && y > 100)) { digitalWrite(RED_LED, HIGH); } else if ((x < 320 && x > 160) && (y > 100 && y < 240)) { digitalWrite(RED_LED, LOW); } else if ((x < 320 && x > 160) && (y > 0 && y < 100)) { drawSettingsScreen(); } } } void drawHomeScreen() { myScreen.clear(); myScreen.gText(30, 50, "TOUCH LCD DEMO", colours[4]); myScreen.rectangle(0, 100, 160, 239, colours[1]); myScreen.gText(50, 180, "ON", colours[0]); myScreen.rectangle(160, 100, 319, 239, colours[0]); myScreen.gText(235, 180, "OFF", colours[1]); myScreen.rectangle(160, 0, 319, 100, colours[2]); myScreen.gText(180, 50, "SETTINGS", colours[3]); } void drawSettingsScreen() { myScreen.clear(); myScreen.gText(10, 10, "TOUCH LCD DEMO", colours[0]); myScreen.gText(10, 30, "TOUCH LCD DEMO", colours[1]); myScreen.gText(10, 50, "TOUCH LCD DEMO", colours[2]); myScreen.gText(10, 70, "TOUCH LCD DEMO", colours[3]); myScreen.gText(10, 90, "TOUCH LCD DEMO", colours[4]); }
  7. iesalais

    MSP432 Hardware SPI Issue

    Hello, I've been trying to run an example called "graphicstest" from adafruit's ST7735 library on a TFT display using an MSP432. My problem is that, for some reason, software SPI works but not hardware SPI. The example "graphicstest" has an option to switch to software SPI by setting the MOSI and SCK pins to whatever i want and when i do that it works, the program does it's little test, but the problem with that is that it runs VERY slow so i kinda need this to work at its intended speed by using hardware SPI. if i hook up MOSI pin to P1.6 and SCK to P1.5 on my MSP432, nothing happens while using hardware SPI. but once i switch to software SPI and set MOSI as pin 15(P1.6) and SCK as pin 7(P1.5), it works. Can anyone help explain what is going on? P.S. this is what the code looks like when changing from Hardware to Software: // For the breakout, you can use any 2 or 3 pins // These pins will also work for the 1.8" TFT shield #define TFT_CS 18 //P3.0 on MSP432 #define TFT_RST 5 #define TFT_DC 8 // Option 1 (recommended): must use the hardware SPI pins // (for UNO thats sclk = 13 and sid = 11) and pin 10 must be // an output. This is much faster - also required if you want // to use the microSD card (see the image drawing example) Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); // Option 2: use any pins but a little slower! #define TFT_SCLK 7 // set these to be whatever pins you like! #define TFT_MOSI 15 // set these to be whatever pins you like! //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
  8. B@tto

    SPI1 on MSP430F5529

    Hi, Little question : is SPI1 available on F5529 ? It's mentionned on pinmapping http://energia.nu/Guide_MSP430F5529LaunchPad.html but when I try to use it, no signal is generated, and when I look in librairies and core, I don't find where it's configurated (setModule() is only for EUSCI peripheral). Regards
  9. Hi everyone. I'm new to this forum and new to TI mcu. Planing to get a launchpad with msp430g2553 I have experience with atmegas, and arduino ide. I have a project to have some sensors around with batteries and a central receiver to publish to internet, the will comunicate vía nrf24l01 which is a SPI device and in the array of sensors some of them are I2C. As I see the description I2C and SPI share the pin in Msp430G2, so my question: is possible to use both in the same project in a reliable way? I did this project with atmega328 and arduino ide but I read the msp430g2553 has better power efficiency and want to give it a try.
  10. Hello there, I'm trying to program the digipot using spi communication to set the ISL23428 digipots to thier maximum values. I used the multimeter to inspect the output voltage for each digipots and the result is zero for both. I'm not sure if the issue is in my code or with the digipots. Thanks in advance for your help. #include <msp430fr5989.h> #include <stdint.h> #define delay(x) __delay_cycles(x * 8000UL) void digitalPotWrite(); uint8_t SPI_transfer(uint8_t _data); uint8_t spi_send(const uint8_t _data); void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer PM5CTL0 &= ~LOCKLPM5; // setup UCB1 UCB1CTLW0 = UCSWRST | UCSSEL_2; // UCSWRST= Put USCI in reset mode, UCSSEL_2 = source USCI clock from SMCLK UCB1CTLW0 |= UCCKPH | UCMSB | UCMST | UCSYNC; //UCCKPH = SPI MODE 0(CPOL=0 CPHA=0) , UCMSB= MSB, UCMST= master mode P3SEL0 |= BIT1; // P3.1-> UCB1SIMO P3SEL1 &= ~ BIT1; P3SEL0 |= BIT2 ; //P3.2-> UCB1SOMI P3SEL1 &= ~ BIT2 ; P3SEL0 |= BIT0 ; //P3.0-> USCB1CLK P3SEL1 &= ~ BIT0 ; P1OUT |= BIT0; P1DIR |= BIT0; // set cs P1.0 as output // UCB1 set initial speed UCB1BR0 |= 0x02; UCB1BR1 = 0; UCB1CTLW0 &= ~UCSWRST; // release UCB1 for operation delay(10); digitalPotWrite(); UCB1CTLW0 = UCSWRST; //spi disable for(;;) { } } void digitalPotWrite() { // take the CS pin low to select the chip: P1OUT &= ~BIT0; delay(10); // send writing instruction to WR0 SPI_transfer(0b11000000); // 110 is writing instruction followed by WR0 address(00000) delay(10); SPI_transfer(0b11111111); // set WR0 to max value delay(10); // send writing instruction to WR1 SPI_transfer(0b11000001); // 110 is writing instruction followed by WR1 address(00001) delay(10); SPI_transfer(0b11111111); // set WR1 to max value delay(10); // take the CS pin high to de-select the chip: P1OUT |= BIT0; } uint8_t SPI_transfer(uint8_t _data) { return spi_send(_data); } uint8_t spi_send(const uint8_t _data) { /* Wait for previous tx to complete. */ while (!(UCB1IFG & UCTXIFG)) // UCB1 flage ; /* Setting TXBUF clears the TXIFG flag. */ UCB1TXBUF = _data; // transfer buffer for UCB1 /* Wait for a rx character? */ while (!(UCB1IFG & UCRXIFG)) // UCB1 flage ; /* Reading clears RXIFG flag. */ return UCB1RXBUF; //reciveing buffer for UCB1 }
  11. Register

    SPI + I2C

    Hi, I'm trying to make a clock with a Tiny RTC module and a iTead 5110 Nokia LCD. I'm using Adafruit RTClib and the energia LCD_5110_SPI. Each library an device are working fine separately but when put together it stops working, is it possible to have SPI and I2C device working simultaneously? Thanks.
  12. Hi, I have a project in which I submit data through a custom message protocol. So like message <321;1;5;10.2> is a thing. To do that I use things like String s = "<310;" + String(DeviceID) + String(";") + String(ToestelID)+ String(";") + String(currentUsrID)+ String(";1;") + String(CurrentPowerUsg) + String(";") + String(Temp1) + String(";") + String(Temp2) + String(";") + String(lichtSterkte) + String(">"); But the conversion of double to string fails. this code double ding = 10.15; Serial.print("double print"); Serial.println(ding); Serial.print("Als string"); Serial.println(String(ding)); String s = "<320;" + String(ding) + String(";"); Serial.println(s); gives me this result: Which is fine. However if I include SPI.h and use the same code I get this result I found this out after starting a new project using all the includes from my original project, and eliminating them 1 by 1. So the SPI include does something to my String conversion... I'm using Energie 1.6.10E18 How can I fix this?
  13. hemangjoshi37a

    MSP430 to Arduino SPI Communication

    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
  14. (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. spiE.zip
  15. 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
  16. mcafzap

    SPI on cc1310

    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
  17. Nick Gammon published an interesting post on using SPI on 16 MHz Arduinos to run WS2812 LEDs (aka neopixels) at: http://gammon.com.au/forum/?id=13357. He also provides a link with a lot of information about the NRZ protocol used by the WS2812 and tolerances: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/. 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 * https://github.com/nickgammon/NeoPixels_SPI * With ideas from: * http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ * Released for public use under the Creative Commons Attribution 3.0 Australia License * http://creativecommons.org/licenses/by/3.0/au/ * * 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.
  18. 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 }
  19. 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.
  20. 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); */ }
  21. 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 LCD_5110_SPI.zip Terminal3.h Terminal6.h Terminal12.h
  22. 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 (http://www.cypress.com/?docID=52945) 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.
  23. 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
  24. Hello, I am having trouble using a SPI DS3234 RTC with Energia and TivaC series launchpad. I am using the ds3234 library at https://github.com/rodan/ds3234 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 http://forum.43oh.com/topic/9016-ds3234-rtc-peek-poke/ 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.
  25. 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.