Esempio n. 1
0
void Init_Dev(void)
{
    setbusclock();
    Port_Init();
    SCI_Init();
    PWM_Init();   
}
Esempio n. 2
0
File: main.c Progetto: SPECNOW/buddy
void setup()
{
    //
    // Configure PLL, disable WD, enable peripheral clocks.
    //
    Device_init();

    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();

    // Initialize Pins as desired
    SCI_Init();
    ADC_Init();
    EQEP_Init();
    GPIO_Init();
    UltraSonic_GPIO_Init();
    UltraSonic_TMR_Init();


    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    EINT;
    ERTM;
}
Esempio n. 3
0
void main(void) 
{

 // int temp_laserStatus;           //定义一个数组用来接受 上下舵机值
  DisableInterrupts;
  SetBusCLK_40M();    //   设置时钟初始化。40MHz.
  PITInit();          //PIT初始
  PWM_Init();
  LIGHT_Init();
  SCI_Init();
  Tect_Speed_Init();    //ECT 捕捉初始
 // AD_Init(); 
  delayms(3200);
  Laser_num();
  EnableInterrupts;
  for(;;) 
  {     
  TestSMinfo(test_info_send);   
  }

          
// _FEED_COP(); /*看门狗,防死循环用的 */
 /* loop forever */
  /* please make sure that you never leave main */
}
Esempio n. 4
0
void main(void) 
{
  EnableInterrupts;
  setbusclock();
  SCI_Init();
  PWM_Init();
  DDRB=0xff;
  for(;;)   {
  }
}
Esempio n. 5
0
void
Init_Peripherals(void)
{
    InitCpuTimers();
    Timer_Init();
    SCI_Init();
    EPwmTimerInit();
    I2CA_Init();
    SPI_Init();
    ECAN_Init();
    EQEP_Init();
    ADC_Init();
    USB_Init();
}
void main(void) {
// Setup and enable ADC channel 0 (AN0)
// Refer to Chapter 14 in S12G Reference Manual for ADC subsystem details
	
	//ADC for all of them
	//ATDCTL0 = 0x01;   // continuous conversion
	ATDCTL1 = 0x4B;		// set for 12-bit resolution, external trigger source is channel 11 
	ATDCTL3 = 0x88;		// right justified, one sample per sequence
	ATDCTL4 = 0x02;		// prescaler = 2; ATD clock = 6.25MHz / (2 * (2 + 1)) == 1.04MHz
	ATDCTL5 = 0x2B;		// continuous conversion on channel 11
  //ATDCTL5 = 0x20;		// continuous conversion on channel 0
  
	//setting the clock 
 CPMUCLKS = 0x80;  //PLLSEL = 1
 CPMUOSC  = 0x00;  //OSCE = 0
 CPMUSYNR = 0x0F;  //VCOFRQ = 0, SYNDIV = 15
 CPMUPOSTDIV = 0x00;  // postdiv=0  
 
 CPMUFLG  = 0x00;
 
 TSCR1=0x90;   //Timer System Control Register 1
 TSCR2=0x00;   //Timer System Control Register 2
 TIOS=0xFE;
 
 PERT=0x01;    //enable pull-up resistor on TIC[0]
  
 TCTL3=0x00;   //TCTL3 & TCTL4 configure which edges to capture
 TCTL4=0x02;   //configured for falling edge on TIC[0]
 
 TIE=0x01;
	
	// bus clock = 16Mhz
	
// Setup LED and SCI
  DDRJ |= 0x01;     // PortJ bit 0 is output to LED D2 on DIG13
  SCI_Init(9600);
  
  EnableInterrupts;
  
  //to make a sampling frequency of 300Hz, add a time delay of 3ms
  for(;;) {
    /*PTJ ^= 0x01;          // toggle LED     
    val1 = ATDDR0;       // read analog input from channel 11
    SCI_OutUDec(val1);    // output analog reading via serial
    OutCRLF();
    delayby1ms(3); 
    */
  }           
}
Esempio n. 7
0
void main(void) {
	EnableInterrupts;
  SetBusCLK_40M();    //   设置时钟初始化。40MHz.
  SCI_Init();
  AD_Init(); //     AD初始化。
  DDRM = 0X1F;        //启动LCD
	LCD_start();  //初始化LCD模块 
	LCD_clear(); //清屏幕 
	
	LCD_startshow();

  for(;;) {
//  TestSMinfo();
  }
}
// Función principal
void main(void)
{
    // Inicialización
    SYSTEM_INIT();
    MCG_Init();
    LCD_Init();
    TPM_Init();
    SCI_Init();
    CLI;


    RealTimeClock_Init();

    for(;;) {
        SEI;
        if(INT_EVENTS==0)WAIT;
        CLI;

        Process_Events();
    }

}
Esempio n. 9
0
void main(void) 
{

 // int temp_laserStatus;           //定义一个数组用来接受 上下舵机值
//  DisableInterrupts;
  SetBusCLK_40M();    //   设置时钟初始化。40MHz.
  //PITInit();          //PIT初始
 // PWM_Init();
 // LIGHT_Init();
  SCI_Init();
 // Tect_Speed_Init();    //ECT 捕捉初始
  AD_Init(); 
  delayms(3200);
 // Laser_num();
//  EnableInterrupts;
  for(;;) 
  {
   // Light_Up();         //激光整排点亮
     
    Collect_IR();   //这两个是红外捕捉和判断红外位置 先注释
    Cross_judge();          
    TestIR(IR_temp_laser_array);

    
  // Clear_baitou();  //position的第一次滤波
 //  baitou_delay++;
 //  if(baitou_delay%8==0) 
 //  {
 //   baitou_delay=1;
  //  baitou( ); //先执行摆头舵机,通过计算得出角度,为第二次滤波做准备
  //  }
     
    
   
  // General_Position();      
  // Collect_Point();
  // Collect_Section();
  // Judge_Slope();
 //  Clear_General();
 //  delay_count++;
   
   
   
   
 //  dajiao();
   
  /*send_count++;
  if(send_count%20==0) {
    send_count=1;
    TestSMinfo(1);  
   }*/   
  
  
//Clear_Speed();
//    SpeedCtrl();  
  
 }
    
 
   
  
  

          
// _FEED_COP(); /*看门狗,防死循环用的 */
 /* loop forever */
  /* please make sure that you never leave main */
}
Esempio n. 10
0
File: Cpu112.c Progetto: ducis/HCS
/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S12DG128_112)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  /* Common initialization of the CPU registers */
  /* PIEP: PIEP5=0 */
  clrReg8Bits(PIEP, 32);                
  /* PTP: PTP5=0,PTP4=0,PTP3=0,PTP1=0 */
  clrReg8Bits(PTP, 58);                 
  /* PERP: PERP5=0 */
  clrReg8Bits(PERP, 32);                
  /* DDRP: DDRP5=1,DDRP4=1,DDRP3=1,DDRP1=1 */
  setReg8Bits(DDRP, 58);                
  /* PEAR: NOACCE=0,PIPOE=0,NECLK=1,LSTRE=0,RDWE=0 */
  clrSetReg8Bits(PEAR, 172, 16);        
  /* PUCR: PUPKE=0,PUPEE=0,PUPBE=0,PUPAE=0 */
  clrReg8Bits(PUCR, 147);               
  /* DDRE: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0 */
  clrReg8Bits(DDRE, 252);               
  /* PTM: PTM4=0,PTM3=0 */
  clrReg8Bits(PTM, 24);                 
  /* WOMM: WOMM4=0,WOMM3=0 */
  clrReg8Bits(WOMM, 24);                
  /* DDRM: DDRM4=1,DDRM3=1 */
  setReg8Bits(DDRM, 24);                
  /* PERM: PERM4=0 */
  clrReg8Bits(PERM, 16);                
  /* PORTK: BIT3=0,BIT0=0 */
  clrReg8Bits(PORTK, 9);                
  /* DDRK: BIT3=1,BIT0=1 */
  setReg8Bits(DDRK, 9);                 
  /* PTS: PTS1=1 */
  setReg8Bits(PTS, 2);                  
  /* DDRS: DDRS1=1,DDRS0=0 */
  clrSetReg8Bits(DDRS, 1, 2);           
  /* PWME: PWME7=0,PWME6=0,PWME5=0,PWME4=0,PWME3=0,PWME2=0,PWME1=0,PWME0=0 */
  setReg8(PWME, 0);                     
  /* PWMCTL: CON45=0,CON23=1,CON01=1,PSWAI=0,PFRZ=0 */
  clrSetReg8Bits(PWMCTL, 76, 48);       
  /* PWMCAE: CAE4=0,CAE3=0,CAE1=0 */
  clrReg8Bits(PWMCAE, 26);              
  /* PWMPOL: PPOL4=0,PPOL3=0,PPOL1=0 */
  clrReg8Bits(PWMPOL, 26);              
  /* PBCTL: PBEN=0 */
  clrReg8Bits(PBCTL, 64);               
  /* TSCR1: TEN=0,TSWAI=0,TSFRZ=0,TFFCA=0 */
  clrReg8Bits(TSCR1, 240);              
  /* DLYCT: ??=0,??=0,??=0,??=0,??=0,??=0,DLY1=0,DLY0=0 */
  setReg8(DLYCT, 0);                    
  /* ICSYS: SH37=0,SH26=0,SH15=0,SH04=0,TFMOD=0,PACMX=0,BUFEN=0,LATQ=0 */
  setReg8(ICSYS, 0);                    
  /* ICOVW: NOVW7=0,NOVW5=0,NOVW0=0 */
  clrReg8Bits(ICOVW, 161);              
  /* TCTL4: EDG0B=1,EDG0A=1 */
  setReg8Bits(TCTL4, 3);                
  /* TCTL3: EDG7B=0,EDG7A=0,EDG5B=0,EDG5A=0 */
  clrReg8Bits(TCTL3, 204);              
  /* TIOS: IOS7=0,IOS5=0,IOS0=0 */
  clrReg8Bits(TIOS, 161);               
  /* PERT: PERT7=0,PERT5=0,PERT0=0 */
  clrReg8Bits(PERT, 161);               
  /* PORTA: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg8(PORTA, 0);                    
  /* DDRA: BIT7=1,BIT6=1,BIT5=1,BIT4=1,BIT3=1,BIT2=1,BIT1=1,BIT0=1 */
  setReg8(DDRA, 255);                   
  /* PORTB: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg8(PORTB, 0);                    
  /* DDRB: BIT7=1,BIT6=1,BIT5=1,BIT4=1,BIT3=1,BIT2=1,BIT1=1,BIT0=1 */
  setReg8(DDRB, 255);                   
  /* TIE: C7I=0,C5I=0 */
  clrReg8Bits(TIE, 160);                
  /* PACTL: CLK1=0,CLK0=0 */
  clrReg8Bits(PACTL, 12);               
  /* ATD0DIEN: IEN0=0 */
  clrReg8Bits(ATD0DIEN, 1);             
  /* ATD1DIEN: IEN0=0 */
  clrReg8Bits(ATD1DIEN, 1);             
  /* CRGINT: LOCKIE=0,SCMIE=0 */
  clrReg8Bits(CRGINT, 18);              
  /* COPCTL: RSBCK=0 */
  clrReg8Bits(COPCTL, 64);              
  /* RDRIV: RDPK=0,RDPE=0,RDPB=0,RDPA=0 */
  clrReg8Bits(RDRIV, 147);              
  /* RDRH: RDRH7=0,RDRH6=0,RDRH5=0,RDRH4=0,RDRH3=0,RDRH2=0,RDRH1=0,RDRH0=0 */
  setReg8(RDRH, 0);                     
  /* RDRJ: RDRJ7=0,RDRJ6=0,RDRJ1=0,RDRJ0=0 */
  clrReg8Bits(RDRJ, 195);               
  /* RDRM: RDRM7=0,RDRM6=0,RDRM5=0,RDRM4=0,RDRM3=0,RDRM2=0,RDRM1=0,RDRM0=0 */
  setReg8(RDRM, 0);                     
  /* RDRP: RDRP7=0,RDRP6=0,RDRP5=0,RDRP4=0,RDRP3=0,RDRP2=0,RDRP1=0,RDRP0=0 */
  setReg8(RDRP, 0);                     
  /* RDRS: RDRS7=0,RDRS6=0,RDRS5=0,RDRS4=0,RDRS3=0,RDRS2=0,RDRS1=0,RDRS0=0 */
  setReg8(RDRS, 0);                     
  /* RDRT: RDRT7=0,RDRT6=0,RDRT5=0,RDRT4=0,RDRT3=0,RDRT2=0,RDRT1=0,RDRT0=0 */
  setReg8(RDRT, 0);                     
  /* INTCR: IRQEN=0 */
  clrReg8Bits(INTCR, 64);               
  /* PACN10: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=0,BIT10=0,BIT9=0,BIT8=0,BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg16(PACN10, 0);                  
  /* ### MC9S12DG128_112 "Cpu112" init code ... */
  /* ### BitIO "ForwardOrBackward" init code ... */
  /* ### ByteIO "E" init code ... */
  /* ### BitIO "MotorEnableM3" init code ... */
  /* ### BitIO "M4" init code ... */
  Shadow_M &= (byte)~16;               /* Initialize pin shadow variable bit */
  /* ### BitIO "K0" init code ... */
  Shadow_K &= (byte)~1;                /* Initialize pin shadow variable bit */
  /* ### BitIO "MotorEnableK3" init code ... */
  /* ### Asynchro serial "SCI" init code ... */
  SCI_Init();
  /* ### Programable pulse generation "Servo1" init code ... */
  Servo1_Init();
  /* ### Programable pulse generation "Servo2" init code ... */
  Servo2_Init();
  /* ### Programable pulse generation "MainMotor" init code ... */
  MainMotor_Init();
  /* ### PulseAccumulator "SpeedSensor" init code ... */
  SpeedSensor_Init();
  /* ### ByteIO "PORTA" init code ... */
  /* ### ByteIO "PORTB" init code ... */
  /* ### Timer capture encapsulation "Cap1" init code ... */
  Cap1_Init();
  /* ### Timer capture encapsulation "Cap2" init code ... */
  Cap2_Init();
  /* ###  "ATC0" init code ... */
  ATC0_Init();
  /* ###  "ATC1" init code ... */
  ATC1_Init();
 /* Common peripheral initialization - ENABLE */
  /* TSCR1: TEN=1 */
  setReg8Bits(TSCR1, 128);              
  __EI();                              /* Enable interrupts */
}