jp430bb 8 Posted July 2, 2015 Share Posted July 2, 2015 I'm back with another issue with my Stellaris LaunchPad. I have a short Energia sketch which uses the SPI library to write to the serial LCD on the ADS1118 Booster Pack. The sketch works as expected. The problem is that it somehow leaves the Stellaris in a state in which it cannot be flashed successfully by lm4flash. I have to connect the Stellaris LaunchPad, flash it (works fine the first time), disconnect the USB cable, reconnect, flash again, and so on. The symptoms seem to match what a TI employee posted on the E2E Community back in 2011, where changing the function of PORTC pins 0 to 3 would interfere with JTAG. However, I couldn't see where my Energia sketch or the SPI library would be doing anything to those PORTC pins. I'm using SPI.setModule(2) to select the Stellaris SPI module which is connected to the proper pins for this Booster Pack. If I flash another Energia sketch which does not use the SPI library, then I can flash over and over again with lm4flash without disconnecting and reconnecting the USB cable. Can someone point me to the problem? Here's what I see if I do the flashing from a MinGW command line: $ # TI Stellaris ICDI/JTAG/SWD Interface driver 2.0.7922.0 $ # Windows 7, 64-bit $ # Just plugged in the Stellaris LaunchPad $ /c/energia-0101E0015/hardware/tools/lm4f/bin/lm4flash.exe -V LM4Flash version 0.1.3 - Flasher for Stellaris Launchpad ICDI boards Copyright (C) 2012 Fabio Utzig <fabio@[member="utzig"].net> Copyright (C) 2012 Peter Stuge <peter@stuge.se> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ /c/energia-0101E0015/hardware/tools/lm4f/bin/lm4flash.exe -v Stellaris_ADS1118_2.cpp.bin Found ICDI device with serial: 0E1011C2 ICDI version: 9270 $ # completed quickly, no problem, sketch is running OK $ /c/energia-0101E0015/hardware/tools/lm4f/bin/lm4flash.exe -v Stellaris_ADS1118_2.cpp.bin Found ICDI device with serial: 0E1011C2 ICDI version: 9270 [output stops here for several seconds, unplug USB cable] Error receiving data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error transmitting data -9 Error verifying flash Error transmitting data -9 Quote Link to post Share on other sites
Rei Vilo 695 Posted July 2, 2015 Share Posted July 2, 2015 I'm not using the ADS1118 BoosterPack, but the Kentec 3.5" SPI screen though SPI(2) port, and I've experienced no issue so far when uploading the sketch again. Does the ADS1118 BoosterPack use any of the Port C pins? Quote Link to post Share on other sites
jp430bb 8 Posted July 3, 2015 Author Share Posted July 3, 2015 I'm not using the ADS1118 BoosterPack, but the Kentec 3.5" SPI screen though SPI(2) port, and I've experienced no issue so far when uploading the sketch again. Does the ADS1118 BoosterPack use any of the Port C pins? The ADS1118 Booster Pack is a 20-pin design, so it doesn't connect to any Stellaris GPIO Port C pins. Quote Link to post Share on other sites
jp430bb 8 Posted July 3, 2015 Author Share Posted July 3, 2015 I'm not getting meaningful data from the ADS1118 on the Booster Pack with the Stellaris LaunchPad and the Energia sketch below. I think the Booster Pack is OK, as it functions normally on an MSP430 Value Line Launch Pad with the demo MSP430G2553 MCU. The LCD stuff in the sketch below works fine with the Stellaris LaunchPad. Any pointers on what I'm doing wrong? // Stellaris LaunchPad with ADS1118 Booster Pack #include <SPI.h> const int LCD_RS = 12; // Register Select const int LCD_CS = 13; // LCD chip select const int ADS1118_CS = 8; // ADS1118 chip select const int BUZZER = 2; // ADS1118 buzzer pin #define ADSCON_CH0 (0x8B8A) #define ADS1118_TS (0x0010) uint16_t ADS1118_config = (ADSCON_CH0 + ADS1118_TS) | 0x8000; void setup() { Serial.begin(9600); Serial.println("-+-+- RESET -+-+-"); SPI.begin(); SPI.setModule(2); SPI.setClockDivider(SPI_CLOCK_DIV64); // MSBFIRST is the default pinMode(BUZZER, INPUT_PULLUP); // initialize the ADS1118 pinMode(ADS1118_CS, OUTPUT); // initialize the LCD pinMode(LCD_RS, OUTPUT); pinMode(LCD_CS, OUTPUT); delay(2); writecom(0x30); // wake up writecom(0x30); // wake up writecom(0x30); // wake up writecom(0x39); // function set writecom(0x14); // internal osc frequency writecom(0x70); // contrast writecom(0x56); // power control writecom(0x6D); // follower control delay(2); writecom(0x0C); // display on writecom(0x01); // clear delay(5); writecom(0x06); // entry mode delay(10); } int counter = 0; void loop() { Serial.print("# loop "); Serial.println(counter++); // make a temperature reading // TODO: this doesn't work! digitalWrite(ADS1118_CS, LOW); delay(2); SPI.setDataMode(0); int msb = SPI.transfer(ADS1118_config >> 8); Serial.print(msb); // prints 128 every time Serial.print(" "); int lsb = SPI.transfer(ADS1118_config & 0xff); Serial.println(lsb); // prints 0 every time msb = (msb << 8) | lsb; int dummy = SPI.transfer(ADS1118_config >> 8); dummy = SPI.transfer(ADS1118_config & 0xff); digitalWrite(ADS1118_CS, HIGH); Serial.println(msb); // prints 32768 every time lcdMoveTo(0x00); // 1st line, 1st column if(counter % 2 == 0) lcdPrintChar(' '); else lcdPrintChar('+'); lcdPrintChar(' '); lcdPrintInt(msb); lcdMoveTo(0x40); // 2nd line, 1st column lcdPrintInt(counter); lcdPrintChar(' '); int now = millis(); lcdPrintInt(now); now = millis(); if(1000 - (now % 1000) > 100) sleep(1000 - (now % 1000)); else sleep((now + 1000) % 1000); } void lcdClear() { writecom(0x01); delay(2); } void lcdMoveTo(byte x) { writecom(0x80 + (x & 0x7f)); delay(1); } void lcdPrintInt(int x) { lcdPrintChar('0' + (x / 100000) % 10); lcdPrintChar('0' + (x / 10000) % 10); lcdPrintChar('0' + (x / 1000) % 10); lcdPrintChar('0' + (x / 100) % 10); lcdPrintChar('0' + (x / 10) % 10); lcdPrintChar('0' + x % 10); } void lcdPrintString(char *s) { while(*s != 0) { lcdPrintChar(*s++); } } void lcdPrintChar(char c) { writedata((byte)c); delay(1); } void writecom(byte d) { digitalWrite(LCD_CS, LOW); digitalWrite(LCD_RS, LOW); // LOW = command SPI.setDataMode(SPI_MODE3); SPI.transfer(d); digitalWrite(LCD_CS, HIGH); delay(1); } void writedata(byte d) { digitalWrite(LCD_CS, LOW); digitalWrite(LCD_RS, HIGH); // HIGH = data SPI.setDataMode(SPI_MODE3); SPI.transfer(d); digitalWrite(LCD_CS, HIGH); delay(1); } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.