Jump to content
jsolarski

32k crystal install and test

Recommended Posts

This is how to install the 32K stock crystal that comes with the MSP430 Launchpad kit

Original post http://justinstech.org/2010/07/msp430-launchpad-dev-kit-how-too/

 

* Supplies

* Launch pad

* 32KHz crystal

* soldering iron

* solder

* headers

* Bright lamp

* electrical tape or tape like substitute

* odds and ends (lol)(tweezers or other tool for manipulation)

 

 

Steps

1) open crystal packagaging and place crystal on launchpad

 

2) more the crystal around with tweezers or other manipulation tool till the leads of the crystal line up with the solder pad

(you may need to use a magnifying glass)

3) tape crystal in place, and adjust so the leads are touching the pads.

DSCN04031-300x225.jpg

4) solder the leads to the pads*** be careful not to bridge the pads, or hold the iron on there too long.

 

5) once you have verified that the leads are soldered, you will have to Ground the casing, there is a small pad opposite of the leads you will want to solder the casing to the pad. after that let it cool for a moment, and double check your work.

 

6) Test- Use the WDT+ to dbl check that your crystal is functioning correctly

IAR or CCS example code taken directly from msp430 example code

//******************************************************************************
// MSP430F20xx Demo - LFXT1 Oscillator Fault Detection
//
// Description: System runs normally in LPM3 with WDT timer clocked by
// 32kHz ACLK with a 1x4 second interrupt. P1.0 is normally pulsed every
// second inside WDT interrupt. If an LFXT1 oscillator fault occurs,
// NMI is requested forcing exit from LPM3. P1.0 is toggled rapidly by software
// as long as LFXT1 oscillator fault is present. Assumed only LFXT1 as NMI
// source - code does not check for other NMI sources.
// ACLK = LFXT1 = 32768, MCLK = SMCLK = Default DCO
//
// //*External watch crystal on XIN XOUT is required for ACLK*//
//
//
// MSP430F20xx
// ---------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// M. Buccini / L. Westlund
// Texas Instruments Inc.
// September 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
//******************************************************************************
#include 
volatile unsigned int i;
void main(void)
{
WDTCTL = WDT_ADLY_1000; // WDT 1s interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
// An immedate Osc Fault will occur next
IE1 |= OFIE; // Enable Osc Fault
while(1)
{
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
}
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer (void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
#pragma vector=NMI_VECTOR
__interrupt void nmi_ (void)
{
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFFF; i > 0; i--); // Time for flag to set
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
}
while (IFG1 & OFIFG); // OSCFault flag still set?
IE1 |= OFIE; // Enable Osc Fault
}

 

MSPGCC version for linux or mac users ***compiles, but is untested on MSP430***will test soon

//******************************************************************************
// MSP430F20xx Demo - LFXT1 Oscillator Fault Detection
//
// Description: System runs normally in LPM3 with WDT timer clocked by
// 32kHz ACLK with a 1x4 second interrupt. P1.0 is normally pulsed every
// second inside WDT interrupt. If an LFXT1 oscillator fault occurs,
// NMI is requested forcing exit from LPM3. P1.0 is toggled rapidly by software
// as long as LFXT1 oscillator fault is present. Assumed only LFXT1 as NMI
// source - code does not check for other NMI sources.
// ACLK = LFXT1 = 32768, MCLK = SMCLK = Default DCO
//
// //*External watch crystal on XIN XOUT is required for ACLK*//
//
//
// MSP430F20xx
// ---------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// M. Buccini / L. Westlund
// Texas Instruments Inc.
// September 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
// modified by justin solarski to work with MSPGCC 4.0
//******************************************************************************
#include  // IAR & CC use #include
#include  //for interrupt handler
volatile unsigned int i;
void main(void)
{
WDTCTL = WDT_ADLY_1000; // WDT 1s interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
// An immedate Osc Fault will occur next
IE1 |= OFIE; // Enable Osc Fault
_enable_interrupt(); // enable interrupts added for mspgcc
while(1)
{
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
}
//#pragma vector=WDT_VECTOR removed for mspgcc
interrupt(WDT_VECTOR) watchdog_timer (void) //__interrupt void watchdog_timer (void) removed for mspgcc
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
//#pragma vector=NMI_VECTOR removed for mspgcc
interrupt(NMI_VECTOR) nmi_ (void) //__interrupt void nmi_ (void) removed for mspgcc
{
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFFF; i > 0; i--); // Time for flag to set
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
}
while (IFG1 & OFIFG); // OSCFault flag still set?
IE1 |= OFIE; // Enable Osc Fault
}

 

 

For MSPGCC you need to add #include to use the interrupt handlers (EG Interrupt(vector) Handler(void) { }

Share this post


Link to post
Share on other sites

You might find this instructable step informative with regards to the 32k crystal.

http://www.instructables.com/id/MSP430-Based-Chronulator-using-Launchpad-chip/step11/Determining-the-32768-kHz-Crystals-load-Capacita/

 

It explains why the crystal's load capacitance needs to be right. It also gives a way that you can check if you have a freq. meter.

Share this post


Link to post
Share on other sites

good post. but what happens if i don't use this external crystal? can it have any downside if i solder it ? i really can't understand why ti didn't pre installed it? : /

Share this post


Link to post
Share on other sites

good post. but what happens if i don't use this external crystal? can it have any downside if i solder it ? i really can't understand why ti didn't pre installed it? : /

I never thought about this. It is a good question.

 

What are the consequences of installing the crystal? What is limited by doing so?

Share this post


Link to post
Share on other sites

You lose the GPIO of those two pins on that launchpad. But for the price of a launchpad... you can get 2, one with and one without... So... who cares? :-P

Which may explain why I purchased 2 from the 43oh store? ;)

Share this post


Link to post
Share on other sites

i just have 14 pins already : / not 20. if i solder i will have 12 pins. if i connect an lcd; i will have 12-6=6 pins left. and if i add a sensor and two buttons and a potentiometer, i guess i will be out of pins :(((( but if i solder the crystal, you say it works more stable right? faster??

Share this post


Link to post
Share on other sites

Not necessarily more more stable or faster, It just has different advantages for using it.

1) more accurate time and less drift

2) low power (it is all low power lol)

 

you have to make the call on if you need that accurate time or not.

Personally I have not used a project that needed a crystal for the final design.

Share this post


Link to post
Share on other sites

i just have 14 pins already : / not 20. if i solder i will have 12 pins. if i connect an lcd; i will have 12-6=6 pins left. and if i add a sensor and two buttons and a potentiometer, i guess i will be out of pins :-(((( but if i solder the crystal, you say it works more stable right? faster??

 

As jsolarski said, you have to make the call. Until now (VFD clock), I've not needed the accuracy of the crystal in any project. However, there are a bunch of ways to use less pins; it just requires creative coding, or additional hardware. You can use a serial LCD, or add a shift register to cut your 6 pins in half or less. Inputs (buttons, pot, sensor) usually only require 1 data pin. I've used the 14-pin chips in several projects.

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.


×
×
  • Create New...