Jump to content
Sign in to follow this  
stasundr

msp430g2553 goes crazy

Recommended Posts

Hi, everyone!

 

(I'm completely newbie, so excuse me if my questions are stupid)
I made my first "device" (pic related). It works fine for a short period of time (like an hour or something like that), but then it goes crazy: led start blinking all the time and device don't respond when I change temperature.

Could you please tell me, what's wrong?

 

 (I tried both - CR3024 battery and 3.3V power supply)

 

#include <msp430.h>
#include <RTCplus.h>

RealTimeClock rtc; //initialise the global RealTimeClock instance

int sensorPin = A3;    // select the input pin for the potentiometer
int ledPin = P1_1;     // select the pin for the LED
int sensorValue = 0;

#ifdef RTCWITHDATE
const char Months[]="JanFebMarAprMayJunJulAugSepOctNovDec";
#endif

void DisplayTime()  //routine to format & print the time to the serial port
{
#ifdef RTCWITHDATE
   const char * MonthText;
#endif
   
   if (rtc.RTC_hr<10) Serial.write('0');
   Serial.print(rtc.RTC_hr);
   Serial.write(':');
   if (rtc.RTC_min<10) Serial.write('0');
   Serial.print(rtc.RTC_min);
   Serial.write(':');
   if (rtc.RTC_sec<10) Serial.write('0');
   Serial.print(rtc.RTC_sec);
#ifdef RTCWITHDATE

   MonthText=Months+(rtc.RTC_month-1)*3;
   
   Serial.write(32);
   if (rtc.RTC_day<10) Serial.write(32);
   Serial.print(rtc.RTC_day);
   Serial.write(32);
   Serial.write(*(MonthText));
   Serial.write(*(MonthText+1));
   Serial.write(*(MonthText+2));
   Serial.write(32);
   Serial.print(rtc.RTC_year);
   
#endif
   Serial.println(" ");
}



void setup()
{
  Serial.begin(9600); //initialise Serial
  
  pinMode(ledPin, OUTPUT);  

  rtc.begin();      //initialise the RTC
  
  rtc.Set_Time(23,59,0); //Set the time to 23:56
#ifdef RTCWITHDATE
  rtc.Set_Date(2013,2,28); //Set the date to 28 Feb 2013
#endif
};

void loop()
{
   DisplayTime();  //call our routine that outputs the time
   
   digitalWrite(ledPin, LOW);
   if (rtc.RTC_min < 5) {
     // CRYSTAL TEST
     //digitalWrite(ledPin, HIGH);
     //delay(25);              
     //digitalWrite(ledPin, LOW);
     //delay(1975);
   } else {
     // THERMISTOR TEST
     sensorValue=analogRead(sensorPin);
     digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
     delay(25);              
     digitalWrite(ledPin, LOW);    // turn the LED off by making the voltage LOW
     delay(sensorValue);
   };  
 };


RTC_ISR(void) {
    rtc.Inc();              // Update chunks
 };

(The overall purpose of this device is just to log temperature on SD card)

post-38733-0-00068000-1416474365_thumb.png

post-38733-0-95945800-1416474371_thumb.png

Share this post


Link to post
Share on other sites

The only thing that jumps out at me is that your LED is connected to the serial RX pin. I know you aren't using serial RX but I wonder if using it in this fashion is interfering with the serial routines.

 

Other than that, the RTCplus library is more RAM hungry than it should be. When I did it, I was aiming for small code size rather than small RAM usage.  The above shouldn't run out of RAM, but if it is only a snippet from a larger piece of code, then it is possible you are encountering RAM problems.

 

As for the suggestion above about crystal capacitors, the MSP430 has built-in crystal caps, which the RTCplus library enables when it enables the 32k crystal.  However, the library does activate the 12.5pF capacitors, which are the ones used by the crystal that ships with the Launchpad.  Check the specs for your crystal and if it requires different values, you can change it in RTCplus.cpp - change the XCAP value in line 45 - XCAP_1 for 6pF, XCAP_2 for 10pF.

Share this post


Link to post
Share on other sites

The only thing that jumps out at me is that your LED is connected to the serial RX pin. I know you aren't using serial RX but I wonder if using it in this fashion is interfering with the serial routines.

 

Other than that, the RTCplus library is more RAM hungry than it should be. When I did it, I was aiming for small code size rather than small RAM usage.  The above shouldn't run out of RAM, but if it is only a snippet from a larger piece of code, then it is possible you are encountering RAM problems.

 

As for the suggestion above about crystal capacitors, the MSP430 has built-in crystal caps, which the RTCplus library enables when it enables the 32k crystal.  However, the library does activate the 12.5pF capacitors, which are the ones used by the crystal that ships with the Launchpad.  Check the specs for your crystal and if it requires different values, you can change it in RTCplus.cpp - change the XCAP value in line 45 - XCAP_1 for 6pF, XCAP_2 for 10pF.

 

Thank you very much! The problem was with that RX pin. Now everything seems to work fine.

Share this post


Link to post
Share on other sites

Four things:

1) Does your Xtal short? it looks like there is solder splattered near its base.

2) If for any reason your rtc.RTC_month goes out of the 1-12 range, you'll be reading from illegal locations.

3) I can't seem to be able to locate R3 (reset pull-down resistor), or R4 (LED). Is one of those inside your DIP socket?

4) There's a diode in your board that is not on the schematic. Why?

Share this post


Link to post
Share on other sites

Four things:

1) Does your Xtal short? it looks like there is solder splattered near its base.

2) If for any reason your rtc.RTC_month goes out of the 1-12 range, you'll be reading from illegal locations.

3) I can't seem to be able to locate R3 (reset pull-down resistor), or R4 (LED). Is one of those inside your DIP socket?

4) There's a diode in your board that is not on the schematic. Why?

 

1) No, it doesn't. It's just glare on a liquid flux.

2) rtc.RTC_month within 1-12 range.

3) LED connected to pull-down resistor by track under the button. R3 is red one in the bottom side.

4) There's no diode in my board. May be you are talking about thermoresistor? 

Share this post


Link to post
Share on other sites

The only thing that jumps out at me is that your LED is connected to the serial RX pin. I know you aren't using serial RX but I wonder if using it in this fashion is interfering with the serial routines.

 

Other than that, the RTCplus library is more RAM hungry than it should be. When I did it, I was aiming for small code size rather than small RAM usage. The above shouldn't run out of RAM, but if it is only a snippet from a larger piece of code, then it is possible you are encountering RAM problems.

 

As for the suggestion above about crystal capacitors, the MSP430 has built-in crystal caps, which the RTCplus library enables when it enables the 32k crystal. However, the library does activate the 12.5pF capacitors, which are the ones used by the crystal that ships with the Launchpad. Check the specs for your crystal and if it requires different values, you can change it in RTCplus.cpp - change the XCAP value in line 45 - XCAP_1 for 6pF, XCAP_2 for 10pF.

Wow I didn't know that caps were built in. Learn something new everyday.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...