#include /* common defines and macros */ #include /* derivative information */ void PRBS_INIT(void); void TO24MHZ(void); interrupt void PRBS_TC0_ISR(void); long unsigned int shiftreg; void main(void) { TO24MHZ( ); PRBS_INIT(); EnableInterrupts; for(;;) {} /* wait forever */ } void PRBS_INIT(void) { DDRT_DDRT0 = 1; TSCR1_TEN=1; TSCR2 = 0b001; //Divide 24 MHz bus clock by 2 TC0 = TCNT+50*12; TFLG1 = 1; TIOS = 1; TIE = 1; shiftreg = 0x7FFFFFFF; //Preset all 31 FFs to 1 } void TO24MHZ(void) { CLKSEL = CLKSEL & 0x7F; // Disengage PLL from system PLLCTL = PLLCTL | 0x40; // Turn on PLL SYNR = 5; REFDV = 0; //Set for 24 MHz Bus Clock while (!(CRGFLG & 8)); //Wait till PLL Locks CLKSEL = CLKSEL | 0x80; //engage PLL into system } interrupt void PRBS_TC0_ISR(void) { char FF0, FF2, FF30; TFLG1 = 1; TC0 = TC0 + 50*12; shiftreg = shiftreg<<1; FF2 = (shiftreg>>2) & 1; FF30 = (shiftreg>>30) & 1; FF0 = FF2 ^ FF30; shiftreg = shiftreg + (unsigned long int) FF0; PTT_PTT0 = FF30; }