/* * main.c */ #include #include /* output values of the synthesizer lines are inverted from the MC145158 as the lines are inverted buffered Set the outputs with defines so moving ports and pins becomes painless. */ #define SYNTH_PORT P1OUT #define SYNTH_DATA BIT0 #define SYNTH_CLOCK BIT1 #define SYNTH_LATCH BIT2 #define SIZE_SYNTH_REF 15 //reg + ctrl size #define SIZE_SYNTH_OUT 18 // ditto //globals uint16_t wd_flag= 0; int main(void) { //watchdog 1/4 second interrupts WDTCTL= WDT_ADLY_250; //enable the watchdog interrupt IE1= WDTIE; P1DIR|= SYNTH_DATA | SYNTH_CLOCK | SYNTH_LATCH; //synthesizer data/clock/latch P1OUT|= SYNTH_DATA | SYNTH_CLOCK | SYNTH_LATCH; //init all high, low at RF board P1DIR|= BIT6; //home of green launchpad led uint16_t reg_ref; uint16_t test_ref= 2880; _enable_interrupt( ); for( ; ; ) { if( ! wd_flag ) continue; reg_ref= test_ref << 2; //14.4Mhz / 2880 = 5Khz reg_ref|= 0x0002; //control bit high for reference register; uint16_t i= 0; for( ; i < SIZE_SYNTH_REF; ++i ) { if( reg_ref & 0x8000 ) SYNTH_PORT&= ~SYNTH_DATA; else SYNTH_PORT|= SYNTH_DATA; SYNTH_PORT&= ~SYNTH_CLOCK; SYNTH_PORT|= SYNTH_CLOCK; reg_ref<<= 1; } //now latch in ref buffer SYNTH_PORT&= ~SYNTH_LATCH; SYNTH_PORT|= SYNTH_LATCH; //blink the led P1DIR^= BIT6; wd_flag= 0; } } #pragma vector=WDT_VECTOR __interrupt void wdt_interrupt( ) { wd_flag= 1; }