Skip to content

Instantly share code, notes, and snippets.

@s-estay
Last active October 28, 2016 00:43
Show Gist options
  • Save s-estay/129fa9fcd3c590c804b8756a06816883 to your computer and use it in GitHub Desktop.
Save s-estay/129fa9fcd3c590c804b8756a06816883 to your computer and use it in GitHub Desktop.
msp430: external crystal test
// test external crystal by observing ACLK frequency on ACLK pin
// ACLK correspond to pin P1.0 in MSP430G2553 (see MSP430G2553 datasheet)
// an external crystal connects to the XIN, XOUT pins
// XIN and XOUT correspond to pins P2.6 and P2.7 respectively in MSP430G2553 (see MSP430G2553 datasheet)
// P1SEL = BIT0 and P1DIR = BIT0 show ACLK in P1.0 (see MSP430G2553 datasheet, pin functions)
// this only works with small crystals in cylindrical package
// stand-alone uC test:
// DVCC to 3.3V
// DVSS to GND
// RST' to 3.3V
// crystal between XIN and XOUT (as close as possible to the uC)
// oscilloscope probe to P1.0 and GND
#include <msp430g2553.h>
#define XT BIT0; // BIT0 P1.0
void main(void){
WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer
BCSCTL3 = LFXT1S_0 + XCAP_3; // external crystal, 12.5pF (this line of code generates the 32,768Hz square signal)
P1SEL = XT; // port select: TA0.TACLK
P1DIR = XT; // port select: ACLK on P1.0
while(1); // do this forever
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment