Example #1
0
/****************************
8M晶振,速度快!
****************************/
void init_device(void)
{ 
    unsigned char i;  
    BCSCTL1&=~XT2OFF;
    do
    {
        IFG1&=~OFIFG;
        for(i=0xff;i;i--);
    }
    while((IFG1&OFIFG)!=0);
    BCSCTL2|=SELM1+SELS;//MCLK=SMCLK=XT2;
    init_timerA();

}
Example #2
0
void main(void){



//Initialize the clock to run the microprocessor
ARC_setup_lv();//sets up initializes the clocks and should be called at the beginning of main
//initCLK();//this is now set up in ARC_setup 
//Initialize the uart to talk with terra term 
P4DIR |= BIT1|BIT2|BIT3|BIT5|BIT6|BIT7;//LIGHT UP LED'S AS OUTPUTS 
P4OUT &= ~(BIT1|BIT2|BIT3|BIT5|BIT6|BIT7);
//P4OUT |= BIT5;
VREGinit();//INITALIZE THE VOLTAGE REGULATOR 
//initUART();//initalize when using TxChar(ch)
//setup I2C for use of UCB1 
initI2C();
 
//set up timer
init_timerA(); // some of the set up is now started in ARC_setup 
mmcInit_msp_off();


setup_launch_detect();
//setup_orbit_start();
UnusedPinSetup();//drive all unused pins to outputs 
GyroOff();
SENSORSoff();
MAGoff();
ACCoff();
RESET_LED();


//Initialize the main task 
initARCbus_pd(BUS_ADDR_LEDL);
// initARCbus(BUS_ADDR_LEDL);

//run MSP test
/*
MSPtest();
//RUN Oscillator Test
OscillatorTest();
//Turn temperature sensor/gyro/SD card on
SENSORSon();
//Turn temperature sensor/gyro/SD card off
 SENSORSoff();
 //Turn accelerometers on
 ACCon();
 //turn accelerometers off
 ACCoff();
 //Turn magnetometers on
 MAGon();
 //Turn magnetometers off
 MAGoff();
 */
 //Test the ADC functionality
 //ADC_test();
 //logging data for launch 
 //launch_data_log();

 //test  finished
 //printf("YOU ARE FINISHED!!!\n\r");

memset(stack1,0xcd,sizeof(stack1));//function memset, sets all values(array stack1, everything equals this value, 
//size of array so everything is changed)
stack1[0]=stack1[sizeof(stack1)/sizeof(stack1[0])-1]=0xfeed;//put marker values at the words before/after the stack. 

memset(stack2,0xcd,sizeof(stack2));  // write known values into the stack
stack2[0]=stack2[sizeof(stack2)/sizeof(stack2[0])-1]=0xfeed; // put marker values at the words before/after the stack

memset(stack3,0xcd,sizeof(stack3));  // write known values into the stack
stack3[0]=stack3[sizeof(stack3)/sizeof(stack3[0])-1]=0xfeed; // put marker values at the words before/after the stack

memset(stack5,0xcd,sizeof(stack5));  // write known values into the stack
stack5[0]=stack5[sizeof(stack5)/sizeof(stack5[0])-1]=0xfeed; // put marker values at the words before/after the stack

memset(stack6,0xcd,sizeof(stack6));  // write known values into the stack
stack6[0]=stack6[sizeof(stack6)/sizeof(stack6[0])-1]=0xfeed; // put marker values at the words before/after the stack

ctl_events_init(&handle_SDcard, 0);


//start timer A (taken from Jesse's code so that I can have an interrupt for my timer)
//start_timerA();
ctl_task_run(&Perif_SetUp,BUS_PRI_LOW,Periferial_SetUp,"ARC Bus Test Program","Periferial_SetUp",sizeof(stack2)/sizeof(stack2[0])-2,stack2+1,0);//side note, the termainal can be used in two ways by either passing the uart functin or the async function 
ctl_task_run(&I2C,BUS_PRI_NORMAL,(void(*)(void*))takeI2Cdata,NULL,"takeI2Cdata",sizeof(stack3)/sizeof(stack3[0])-2,stack3+1,0);
ctl_task_run(&LaunchData,BUS_PRI_HIGH,launch_data_log,NULL,"launch_data_log",sizeof(stack1)/sizeof(stack1[0])-2,stack1+1,0);//&LaunchData takes the address
ctl_task_run(&LEDL_events,BUS_PRI_NORMAL+10,sub_events,NULL,"sub_events",sizeof(stack6)/sizeof(stack6[0])-2,stack6+1,0);//this is to run orbit code
//ctl_task_run(&LaunchDetect,4,VerifyLaunchDetect,NULL,"VerifyLaunchDetect",sizeof(stack5)/sizeof(stack5[0])-2,stack5+1,0);
//of the variable which is the task structure is ,2 is the priority,launch_data_log is the function I want to run,"launch_data_log" is 
//the name when I look at the threads window to identify the task,the size of the memory stack minus the guard bits,
//first location where data is stored second element in array (first element is guard bit), the zero is a placeholder
//since the MSP doesn't support this function. 


//put this here for now
ctl_task_run(&ACDS_sen_task,BUS_PRI_LOW+10,ACDS_sensor_interface,NULL,"ACDS_sensor_interface",sizeof(stack5)/sizeof(stack5[0])-2,stack5+1,0);

//Use I2C sensor function to receive data


 //Stay in an infinite loop
//for(;;){// taken care of in main loop
//P5SEL |= BIT6;//OUTPUT aclk
//P5DIR |= BIT6;//output aclk

mainLoop_lp();

mainLoop();

}
Example #3
0
int main( void )
{
	// Stop watchdog timer to prevent time out reset
	WDTCTL = WDTPW + WDTHOLD;
	init_device();
	InitLCM();
	WriteCom(0x3f,'L');//play on;
	WriteCom(0x3f,'R');
	ClearLCM();
	checkflash();
	
	P6SEL|=0x01;
	ADC12CTL0=ADC12ON+SHT0_2+REFON+REF2_5V;
	ADC12CTL1=SHP;
	ADC12MCTL0=SREF_1;
	
	WriteChinese(hzstr,0,0,'L');
	WriteChinese(hzstr+32,0,16,'L');
	WriteChinese(hzstr+64,0,32,'L');
	WriteChinese(hzstr+96,2,0,'L');
	WriteChinese(hzstr+128,2,16,'L');
	WriteChinese(hzstr+160,2,32,'L');
	
	WriteChar(Ezk+16*('m'-0x20),6,40,'L');
	WriteChar(Ezk+16*('V'-0x20),6,48,'L');
	
	ADC12CTL0|=ENC;
	ADC12CTL0|=ADC12SC;
	while(1)
	{
		kkk_showAD(0);
		k=keyscan();
		if(k==12)
		{
			while(k)//等待按键弹起
			{
				k=keyscan();
			}
                        close_timerA();
			ClearLCM();
			kkk_setparameter();
			ClearLCM();
			WriteChinese(hzstr,0,0,'L');
			WriteChinese(hzstr+32,0,16,'L');
			WriteChinese(hzstr+64,0,32,'L');
			WriteChinese(hzstr+96,2,0,'L');
			WriteChinese(hzstr+128,2,16,'L');
			WriteChinese(hzstr+160,2,32,'L');
			
			WriteChar(Ezk+16*('m'-0x20),6,40,'L');
			WriteChar(Ezk+16*('V'-0x20),6,48,'L');
			kkk_showAD(0);
                        init_timerA();
		}
		if(k==15)//reset
		{
			while(k)//等待按键弹起
			{
				k=keyscan();
			}
			WDTCTL =WDT_MRST_32;
			while(1);
		}
		delay(2000);
	}
}