Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


phaseform last won the day on September 29 2015

phaseform had the most liked content!

About phaseform

  • Rank

Profile Information

  • Interests
    South Australia
  1. Thanks Fmilburn, the example you linked looks like it will be fine
  2. I don't understand how TI brought this out to go against Arduino when example codes for the hardware are so scarce, clearly they don't focus on the hobbyist market, or at least they really suck at doing it. Energia is linked on the launchpad website.. should it be confusing something as simple as power management would appear so tricky. I guess I'm just going to keep poking it with a stick until it works?
  3. Ok so I want to save battery life, I thought I could get the chip to power down when hibernating (which I assumed meant main would not run?). I also thought not as relevantly I could save power by powering via vbus and removing the jumper pin to (I hoped) disconnect the debug chip... I dont need calendar mode since I'm using a timedate library. Am I totally misunderstanding the hibernate module??!
  4. Trying to get the hibernate library to work as in the pastebin example for the tm4c123 here. I've modified it with the request at the end. //#include <DateTimeLibrary.h> #include "driverlib/hibernate.c" boolean redstate = false; boolean bluestate = false; int green = 0; void setup() { uint32_t hibact = HibernateIsActive(); // put your setup code here, to run once: pinMode(GREEN_LED, OUTPUT); pinMode(BLUE_LED, OUTPUT); HibernateEnableExpClk(F_CPU); HibernateRTCEnable(); HibernateRTCMatchSet(0,HibernateRTCGet()+5); HibernateIntRegister(HibernateHandler); HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0); HibernateRTCTrimSet(0x7FFF); } void HibernateHandler(void) { //Use this to reset interrupt flag uint32_t ui32Status = HibernateIntStatus(1); HibernateIntClear(ui32Status); //Place here code to execute every second, ex: LCD or 7 segment display //Altough it should be as fastest as possible redstate = !redstate; //To keep the interrupt hapening every second you need this HibernateRTCMatchSet(0,HibernateRTCGet()+5); } void loop() { // put your main code here, to run repeatedly: bluestate = !bluestate; if(redstate ==0){ green = 0; } else green = 64; analogWrite(GREEN_LED, green); if (bluestate) { analogWrite(BLUE_LED, 64); } else { analogWrite(BLUE_LED, 0); } delay(750); HibernateRequest(); } Been reading through 16.2 API Functions for the hibernate module here and can figure out whats going on. I just want the hibernate module to be requested once main has run, this doesn't seem to happen and the hibernate interrupt just seems to function as a timer running alongside the main function...??? Tried adding HibernateWakeSet(HIBERNATE_WAKE_RTC); to the setup
  5. is something required in main to go to sleep, HibernateRequest(void)?
  6. Credit to pixelk for this code: (I changed the NTP server, removed some possible infinite loops and put it in an Energia sketch) /* ESP8266 connected to Serial1 */ void setup() { // initialize both serial ports: Serial.begin(9600); Serial1.begin(9600); Serial.println("..."); } void loop() { delay(3000); Serial.println(); Serial.println("Getting time.."); int Epoch = GetTime(); Serial.print("Epoch is: "); Serial.println(Epoch); delay(5000); } const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets unsigned long GetTime() { String cmd = "AT+CIPSTART=\"UDP\",\"\",123"; // NTP server Serial1.println(cmd); delay(2000); if(Serial1.find("Error")){ Serial.print("RECEIVED: Error"); return 0; } int counta = 0; memset(packetBuffer, 0, NTP_PACKET_SIZE); // Initialize values needed to form NTP request // (see URL above for details on the packets) packetBuffer[0] = 0b11100011; // LI, Version, Mode packetBuffer[1] = 0; // Stratum, or type of clock packetBuffer[2] = 6; // Polling Interval packetBuffer[3] = 0xEC; // Peer Clock Precision Serial1.print("AT+CIPSEND="); Serial1.println(NTP_PACKET_SIZE); if(Serial1.find(">")) { for (byte i = 0; i < NTP_PACKET_SIZE; i++) { Serial1.write(packetBuffer[i]); delay(5); } }else{ Serial1.println("AT+CIPCLOSE"); return 0; } //Serial1.find("+IPD,48:"); int acksize = NTP_PACKET_SIZE + 1 + 2 + 8; // ESP8266 adds a space, a CRLF and starts with "+IPD,48:" Serial.println("ESP2866 ACK : "); for (byte i = 0; i < acksize; i++) { while (Serial1.available() == 0) // you may have to wait for some bytes { counta += 1; Serial.print("."); delay(100); if (counta == 15){ return 0; } } byte ch = Serial1.read(); if (ch < 0x10) Serial.print('0'); Serial.print(ch,HEX); Serial.print(' '); if ( (((i+1) % 15) == 0) ) { Serial.println(); } } Serial.println(); Serial.println(); memset(packetBuffer, 0, NTP_PACKET_SIZE); Serial.println("Server answer : "); int i = 0; while (Serial1.available() > 0) { byte ch = Serial1.read(); if (i <= NTP_PACKET_SIZE) { packetBuffer[i] = ch; } if (ch < 0x10) Serial.print('0'); Serial.print(ch,HEX); Serial.print(' '); if ( (((i+1) % 15) == 0) ) { Serial.println(); } delay(5); i++; if ( ( i < NTP_PACKET_SIZE ) && ( Serial1.available() == 0 ) ) { while (Serial1.available() == 0) // you may have to wait for some bytes { counta += 1; Serial.print("!"); delay(100); if (counta == 15){ return 0; } } } } Serial.println(); Serial.println(); Serial.print(i+1); Serial.println(" bytes received"); // will be more than 48 Serial.print(packetBuffer[40],HEX); Serial.print(" "); Serial.print(packetBuffer[41],HEX); Serial.print(" "); Serial.print(packetBuffer[42],HEX); Serial.print(" "); Serial.print(packetBuffer[43],HEX); Serial.print(" = "); unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): unsigned long secsSince1900 = highWord << 16 | lowWord; Serial.print(secsSince1900,DEC); // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: const unsigned long seventyYears = 2208988800UL; // subtract seventy years: unsigned long epoch = secsSince1900 - seventyYears; unsigned long DST = 60*60*2; // adjust to your GMT+DST unsigned long timestamp = epoch + DST; Serial.println(); Serial.print("Epoch : "); Serial.println(epoch,DEC); return epoch; }
  7. Just been able to get an RTC output on an I2C LCD working on a TM4C123. Using this RTC Library which I understand uses the chips built in RTC/hibernate function and this I2C LCD Library, which seems to only like I2C(3) // Core library for code-sense - IDE-based #if defined(WIRING) // Wiring specific # include "Wiring.h" #elif defined(ENERGIA) // LaunchPad specific # include "Energia.h" #else // error # error Platform not defined #endif // end IDE // Include application, user and local libraries // The time library provides all the tools. // No need for reinventing them! #include "time.h" #define CEST 2*60*60 #include "DateTimeLibrary.h" const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets //LCD #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x27 for a 16 character, 2 line display // Prototypes char * datestamp = __DATE__; char * timestamp = __TIME__; // Define variables and constants time_t myEpochRTC; tm myTimeRTC; DateTime myRTC; // Add setup code void setup() { Wire.begin(3); Wire.setModule(3); lcd.init(); // initialize the lcd Serial.begin(9600); delay(300); myRTC.begin(); myRTC.setTimeZone(tz_GMT); Serial.print("*** datestamp = "); Serial.println(datestamp); Serial.print("*** timestamp = "); Serial.println(timestamp); // Fri, 31 Jul 2015 20:41:48 GMT myEpochRTC = 946743570; // Set time to RTC, only once myRTC.setTime(myEpochRTC); Serial.print("Set RTC = "); Serial.println(myEpochRTC, DEC); myEpochRTC = 0; } // Add loop code void loop() { lcd.backlight(); lcd.setCursor(0,0); lcd.print("Session time:"); // Local time zone myEpochRTC = myRTC.getLocalTime(); lcd.setCursor(0,1); //lcd.print(stringDateTime(myEpochRTC)); // Even more flexible output! // see http://www.cplusplus.com/reference/ctime/strftime/ convertEpoch2Structure(myEpochRTC, myTimeRTC); lcd.print(stringFormatDateTime("%I:%M:%S %p.", myTimeRTC)); delay(100); }
  8. In the sketchbook location (under file > preferences) is a libraries folder, extract your library there
  9. would someone be able to explain the function of hibernate, in post #21 I don't understand why main is running concurrently to the hibernate timer?
  10. I'm just thinking in as far as using the launchpad for a project, unless I'm understanding the process wrong, the debugging chip is only used as usb serial and debugging? Yer thats what I thought, if I remove the jumper possibly I could remove the ICDI from VBUS? then I'd just have to use an external 5v other than USB..?
  11. How can I remove power from the ICDI on a Launchpad board? It seems my lm4f120 will use 40mA through my usb power meter when in sleep, and 70mA when not in sleep.. (sleepSeconds) I've been looking through the users manual on the product page and can't find anything useful in the scematic or the hibernate section.
  12. On the stellaris, is it possible to power from VBUS while using debug usb? I was intending to use the debug serial sometimes to connect to the board, but I want it to run all the time, even when not connected to the debug USB. Is this possible?! I was going to source a 5v power supply to run the VBUS. thanks!
  13. Heres the Library I modified to work with the Stellaris, not sure how that affects the MSP430 Mfrc522_Stellaris.zip
  14. I've been trying to get this library to work with my Stellaris, which has proved a bit of a challenge for a beginner like myself.. I edited Mfrc522.cpp where I changed Mfrc522::Mfrc522(int chipSelectPin, int NRSTPD) { pinMode(chipSelectPin, OUTPUT); _chipSelectPin = chipSelectPin; pinMode(NRSTPD, OUTPUT); digitalWrite(NRSTPD, HIGH); _NRSTPD = NRSTPD; } to Mfrc522::Mfrc522(int chipSelectPin, int NRSTPD) { _chipSelectPin = chipSelectPin; _NRSTPD = NRSTPD; } and moved pinMode(chipSelectPin, OUTPUT); pinMode(NRSTPD, OUTPUT); digitalWrite(NRSTPD, HIGH); to setup (void) of the sketch. NERDGASM! only took about 10 hrs, but I have a card read! fk yeah! For my setup I've set int chipSelectPin = 2; //SDA on reader - connected to pin2 aka CS(2) int NRSTPD = 17; // aka PF_0 I've found out that Mfrc522 Mfrc522(chipSelectPin,NRSTDP); doesnt match Mfrc522.cpp, where the variable NRSTPD is used, so I changed NRSTDP to NRSTPD in the sketch. here is my working code: /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. Modified by phaseform for use with the Stellaris */ // pin mapping for SPI(2) on the Stellaris (also tiva??) using Rei Vilo's pinmap // SDA - CS(2) -> PB_5 = pin 2 as an integer // SCK - SCK(2) -> PB_4 // Mosi - MOSI(2) -> PB_7 // Miso - MISO(2) -> PB_6 // IRQ - Not connected // GND - GND // RST - reset -> PF_0 // VCC - +3.3V = pin 1 #include <Mfrc522.h> #include <SPI.h> int chipSelectPin = 2; //SDA on reader - connected to pin2 aka CS(2) int NRSTPD = 17; //aka PF_0 Mfrc522 Mfrc522(chipSelectPin, NRSTPD); //changed NRSTDP to NRSTPD unsigned char serNum[5]; void setup() { Serial.begin(9600); // using serial port 1 (USB) SPI.setModule(2); // using SPI module 2... pinMode(chipSelectPin, OUTPUT); //moved this here from Mfrc522.cpp digitalWrite(chipSelectPin, LOW); pinMode(NRSTPD, OUTPUT); //moved this here from Mfrc522.cpp digitalWrite(NRSTPD, HIGH); //moved this here from Mfrc522.cpp pinMode(BLUE_LED, OUTPUT); pinMode(RED_LED, OUTPUT); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; String mynum = ""; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); digitalWrite(BLUE_LED, HIGH); delay(1000); digitalWrite(BLUE_LED, LOW); } else{ digitalWrite(RED_LED, HIGH); Serial.println("no dice here"); delay(1000); digitalWrite(RED_LED, LOW); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { digitalWrite(BLUE_LED, HIGH); delay(1000); digitalWrite(BLUE_LED, LOW); Serial.println("The card's number is : "); Serial.print(serNum[0]); Serial.print(" , "); Serial.print(serNum[1],BIN); Serial.print(" , "); Serial.print(serNum[2],BIN); Serial.print(" , "); Serial.print(serNum[3],BIN); Serial.print(" , "); Serial.print(serNum[4],BIN); Serial.println(" "); // Should really check all pairs, but for now we'll just use the first if(serNum[0] == 29) { Serial.println("Hello Eelco"); digitalWrite(BLUE_LED, HIGH); delay(1000); digitalWrite(BLUE_LED, LOW); } delay(1000); } else{ digitalWrite(RED_LED, HIGH); Serial.println("no dice"); delay(1000); digitalWrite(RED_LED, LOW); } Mfrc522.Halt(); }
  • Create New...