SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By omerd29
Hello ,

I'm using MSP430F5131 micro-controller .

I'm using an external oscillator of 12.8MHz which connected to pins PJ.4 and PJ.5 and defined P2.4 ( with timer : TD0.0) as my 1 pulse per second output.

I would like to generate a 1 pulse per second using this external oscillator through P2.4 . In addition to this 1 PPS i got a toggle switch that toggles between a "normal" 1 pulse per second and a "bad" pulse of 0.5 second.

First of all i would like to know how to write a proper code of 1PPS and then i would like to implement both of the pulses ("normal" and "bad") into the code.

second of all i would also like to know if i should defind the PJ.4 and PJ.5 (XIN and XOUT) of the external oscillator in the code as inputs, if so , i would like to know how to implement that in the code.

I have written a code of a 1PPS , i'm not sure if i have written it correctly :

TD0CCR0=49999; // setting TAR count up value -1

TD0CCTL0=CCIE; //enabling interuption

TD0CTL0 =MC_1|ID_3|IDEX_3|TDSSEL_0|TDCLR; //defining timer d TD0.0 (P2.4)

__enable _interrupt ();


if ((P1IN & BIT2)==0) { //ACTIVE LOW


__interrupt void TD0_ISR (void){

P2OUT ^=BIT4;//TOGGLE THE 1PPS PULSE ('1' - '0' )




Thanks in advance.