Beispiel #1
0
//=============================================================================
//--------------------------------------------------------------------
void TestOutput()
{
	DWORD t=0;
	
	//if(Fsu22.Timer_Test<10) return;
	
	Fsu22.Timer_Test=10;
	
	STRB1=0;
	D_STRB1=1;
	Sleep_1_5mk();
	__DI();
	Fsu22.Test.bits.O1= ~(K1 | K2);
	Fsu22.Test.bits.O2= ~(K3 | K4);
	Fsu22.Test.bits.O3= ~(K5 | K6);
	__EI();
	D_STRB1=0;
	STRB1=1;
	
	
	STRB2=0;
	D_STRB2=1;
	Sleep_1_5mk();
	__DI();
	Fsu22.Test.bits.O4= ~(K1 | K2);
	Fsu22.Test.bits.O5= ~(K3 | K4);
	Fsu22.Test.bits.O6= ~(K5 | K6);
	__EI();
	D_STRB2=0;
	STRB2=1;
	
	D_STRB3=1;
	STRB3=0;
	Sleep_1_5mk();
	__DI();
	Fsu22.Test.bits.O7= ~(K1 | K2);
	Fsu22.Test.bits.O8= ~(K3 | K4);
	Fsu22.Test.bits.O9= ~(K5 | K6);
	__EI();
	D_STRB3=0;
	STRB3=1;
	
	D_STRB4=1;
	STRB4=0;
	Sleep_1_5mk();
	__DI();
	Fsu22.Test.bits.O10= ~(K1 | K2);
	Fsu22.Test.bits.O11= ~(K3 | K4);
	Fsu22.Test.bits.O12= ~(K5 | K6);
	__EI();
	D_STRB4=0;
	STRB4=1;
}
Beispiel #2
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MC9S08JM60_64)
**
**     Description :
**         Initializes components 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 */
  /* PTASE: PTASE5=0,PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */
  clrReg8Bits(PTASE, 0x3FU);            
  /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */
  setReg8(PTBSE, 0x00U);                
  /* PTCSE: PTCSE6=0,PTCSE5=0,PTCSE4=0,PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */
  clrReg8Bits(PTCSE, 0x7FU);            
  /* PTDSE: PTDSE7=0,PTDSE6=0,PTDSE5=0,PTDSE4=0,PTDSE3=0,PTDSE2=0,PTDSE1=0,PTDSE0=0 */
  setReg8(PTDSE, 0x00U);                
  /* PTESE: PTESE7=0,PTESE6=0,PTESE5=0,PTESE4=0,PTESE3=0,PTESE2=0,PTESE1=0,PTESE0=0 */
  setReg8(PTESE, 0x00U);                
  /* PTFSE: PTFSE7=0,PTFSE6=0,PTFSE5=0,PTFSE4=0,PTFSE3=0,PTFSE2=0,PTFSE1=0,PTFSE0=0 */
  setReg8(PTFSE, 0x00U);                
  /* PTGSE: PTGSE5=0,PTGSE4=0,PTGSE3=0,PTGSE2=0,PTGSE1=0,PTGSE0=0 */
  clrReg8Bits(PTGSE, 0x3FU);            
  /* PTADS: ??=0,??=0,PTADS5=1,PTADS4=1,PTADS3=1,PTADS2=1,PTADS1=1,PTADS0=1 */
  setReg8(PTADS, 0x3FU);                
  /* PTBDS: PTBDS7=1,PTBDS6=1,PTBDS5=1,PTBDS4=1,PTBDS3=1,PTBDS2=1,PTBDS1=1,PTBDS0=1 */
  setReg8(PTBDS, 0xFFU);                
  /* PTCDS: ??=0,PTCDS6=1,PTCDS5=1,PTCDS4=1,PTCDS3=1,PTCDS2=1,PTCDS1=1,PTCDS0=1 */
  setReg8(PTCDS, 0x7FU);                
  /* PTDDS: PTDDS7=1,PTDDS6=1,PTDDS5=1,PTDDS4=1,PTDDS3=1,PTDDS2=1,PTDDS1=1,PTDDS0=1 */
  setReg8(PTDDS, 0xFFU);                
  /* PTEDS: PTEDS7=1,PTEDS6=1,PTEDS5=1,PTEDS4=1,PTEDS3=1,PTEDS2=1,PTEDS1=1,PTEDS0=1 */
  setReg8(PTEDS, 0xFFU);                
  /* PTFDS: PTFDS7=1,PTFDS6=1,PTFDS5=1,PTFDS4=1,PTFDS3=1,PTFDS2=1,PTFDS1=1,PTFDS0=1 */
  setReg8(PTFDS, 0xFFU);                
  /* PTGDS: ??=0,??=0,PTGDS5=1,PTGDS4=1,PTGDS3=1,PTGDS2=1,PTGDS1=1,PTGDS0=1 */
  setReg8(PTGDS, 0x3FU);                
  /* ### Shared modules init code ... */
  __EI();                              /* Enable interrupts */
}
Beispiel #3
0
void Operate_Max1329_RegMode(BYTE Num, BYTE RW, BYTE Adr, BYTE Count)
{
	BYTE i;
	
	if(Num == 0xFF) SelectAll_DAC();
	else SelectSPI_DAC(Num);
	__DI();
	
	pak_spi_rm.data = 0;
	pak_spi_rm.bits.RW	= RW;
	pak_spi_rm.bits.adr	= Adr;
	Send_SIO(pak_spi_rm.data);
		
	if(RW == READ_MODE_SPI)
	{
		for(i=0;i<Count;i++)
			Spi_Buf_In[i] = Send_SIO(0);
		stop_sio();
	}else
	{
		for(i=0;i<Count;i++)
			Send_SIO(Spi_Buf_Out[i]);
		stop_sio();
	}
	__EI();
	UnSelectAll_DAC();
}
Beispiel #4
0
//===================================================================
void Driver_NDD20P1()
{
	BYTE i;
	i=ADDR;	
	Ndd.Info.bits.Addr	=i;
	if(i!=ADDR_NODE)
	{
		setState(Initialisation);
		ADDR_NODE			=ADDR;
	}
	__DI();
	Ndd.Info.bits.Mode		=MODE;
	
	if(Ndd.PowerNew !=	Ndd.PowerOld)
	{
		for(i=0;i<4;i++)
		{
			if(digit(Ndd.PowerOld,i) != digit(Ndd.PowerNew,i))
			{
				Ndd.St1[i]		=1;
				Ndd.Timer2[i]	=0;
				Ndd.CurStep[i]	=0;
			}
		}
		Ndd.PowerOld = Ndd.PowerNew;
	}
	//=========================================
	for(i=0;i<4;i++)
		UpdateDataSector(i);
	//=========================================
	__EI();
}
Beispiel #5
0
Datei: api.c Projekt: el303/pses
void api_init(void) {
	CILCR_LVL = 0;
	interrupts_init();

	// button
	PIER07_IE0 = 1;
	PIER07_IE1 = 1;
	PIER07 |= 0x0c;
	PUCR07 |= 0x0c;

	Sema = 0;
	vSemaphoreCreateBinary(Sema);

	//Seg_Init();
	Drive_Init();

	//FRAM_Init();

	Us_Init();
	//CarId_Init();
	ADC_Init();
	Battery_Init();
	Linesensor_Init();

	//wirelessInit();

	Serial_Init();

	__EI();
}
Beispiel #6
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MKL25Z128LK4)
**
**     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)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
      /* Initialization of the SIM module */
        /* Initialization of the RCM module */
  /* RCM_RPFW: RSTFLTSEL=0 */
  RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));                                   
  /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
  RCM_RPFC &= (uint8_t)~(uint8_t)(
               RCM_RPFC_RSTFLTSS_MASK |
               RCM_RPFC_RSTFLTSRW(0x03)
              );                                   
        /* Initialization of the FTFL_FlashConfig module */
      /* Initialization of the PMC module */
  /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
  PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
                PMC_LVDSC1_LVDIE_MASK |
                PMC_LVDSC1_LVDV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC1_LVDACK_MASK |
                PMC_LVDSC1_LVDRE_MASK
               ));                                  
  /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
  PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
                PMC_LVDSC2_LVWIE_MASK |
                PMC_LVDSC2_LVWV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC2_LVWACK_MASK
               ));                                  
  /* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
  PMC_REGSC &= (uint8_t)~(uint8_t)(
                PMC_REGSC_BGEN_MASK |
                PMC_REGSC_ACKISO_MASK |
                PMC_REGSC_BGBE_MASK
               );                                   
  /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
  SMC_PMPROT = 0x00U;                  /* Setup Power mode protection register */
  /* Common initialization of the CPU registers */
  /* NVIC_IPR6: PRI_24=0 */
  NVIC_IPR6 &= (uint32_t)~(uint32_t)(NVIC_IP_PRI_24(0xFF));                                   
  /* PORTA_PCR20: ISF=0,MUX=7 */
  PORTA_PCR20 = (uint32_t)((PORTA_PCR20 & (uint32_t)~(uint32_t)(
                 PORT_PCR_ISF_MASK
                )) | (uint32_t)(
                 PORT_PCR_MUX(0x07)
                ));                                  
  /* NVIC_IPR1: PRI_6=0 */
  NVIC_IPR1 &= (uint32_t)~(uint32_t)(NVIC_IP_PRI_6(0xFF));                                   
  /* ### Init_USB_OTG "USB0" init code ... */
  USB0_Init();
  /* ### RingBufferUInt8 "Tx1" init code ... */
  Tx1_Init();
  /* ### RingBufferUInt8 "Rx1" init code ... */
  Rx1_Init();
  (void)USB1_Init();
  __EI();
}
Beispiel #7
0
// р рывани  Reload Timer 1 
__interrupt void ReloadTimer1(void) 
{
	__DI();	
	TMCSR1_UF = 0;       			/* reset underflow interrupt request flag */
	//receiveMsgHandler(0);	
	//receiveMsgHandler(1);
	__EI();	
}
Beispiel #8
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MKL46Z256MC4)
**
**     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)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
      /* Initialization of the SIM module */
  /* PORTA_PCR4: ISF=0,MUX=7 */
  PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK
               )) | (uint32_t)(
                PORT_PCR_MUX(0x07)
               ));                                  
        /* Initialization of the RCM module */
  /* RCM_RPFW: RSTFLTSEL=0 */
  RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));                                   
  /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
  RCM_RPFC &= (uint8_t)~(uint8_t)(
               RCM_RPFC_RSTFLTSS_MASK |
               RCM_RPFC_RSTFLTSRW(0x03)
              );                                   
        /* Initialization of the FTFL_FlashConfig module */
      /* Initialization of the PMC module */
  /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
  PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
                PMC_LVDSC1_LVDIE_MASK |
                PMC_LVDSC1_LVDV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC1_LVDACK_MASK |
                PMC_LVDSC1_LVDRE_MASK
               ));                                  
  /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
  PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
                PMC_LVDSC2_LVWIE_MASK |
                PMC_LVDSC2_LVWV(0x03)
               )) | (uint8_t)(
                PMC_LVDSC2_LVWACK_MASK
               ));                                  
  /* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
  PMC_REGSC &= (uint8_t)~(uint8_t)(
                PMC_REGSC_BGEN_MASK |
                PMC_REGSC_ACKISO_MASK |
                PMC_REGSC_BGBE_MASK
               );                                   
  /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
  SMC_PMPROT = 0x00U;                  /* Setup Power mode protection register */
  /* Common initialization of the CPU registers */
  /* PORTA_PCR20: ISF=0,MUX=7 */
  PORTA_PCR20 = (uint32_t)((PORTA_PCR20 & (uint32_t)~(uint32_t)(
                 PORT_PCR_ISF_MASK
                )) | (uint32_t)(
                 PORT_PCR_MUX(0x07)
                ));                                  
  /* NVIC_IPR1: PRI_6=0 */
  NVIC_IPR1 &= (uint32_t)~(uint32_t)(NVIC_IP_PRI_6(0xFF));                                   
  /* ### Serial_LDD "IO1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
  (void)IO1_Init(NULL);
  __EI();
}
Beispiel #9
0
/**
 ******************************************************************************
 ** Main application to control the program flow
 *****************************************************************************/
void main(void)
{
    // Initialize all interrupt levels of resources
    Vectors_InitIrqLevels();
    // Allow all interrupt levels
    __set_il(7);
    // Enable interrupts
    __EI();

 	Flash_EnableWriting();
 	InitLCD();
 	
 	#if ((SMC_TYPE != SMC_TYPE_R200) && (ZPD == ZPD_ENABLE))
 		ZPD_Init();	
 		//ќжидание окончани¤ ZPD
 		while (m_enSmcMode == Zpd)
 		{
			WDTCP = 0x00;    		
 		}
 	#else 	
	 	m_enSmcMode = NormalDriving;
	#endif

	InitSMC(20);
	Timer_Init();
	InitADC();
	InitRTC();
	
// ≈сли двигатель R200 или ZPD не активно
	#if ((SMC_TYPE == SMC_TYPE_R200) || (ZPD == ZPD_DISABLE))	
		ZeroPosSMC();
		Timer_Wait(TIMER_ID_MAIN, 2000, TRUE);  
	#endif
		
	ClearPosSMC();
	
	DriverInit();
	InitFRTimer0();
	InitExtInt0(); //test

	Init_4_imp();
	InitBacklight();
	Button_Init(ButtonCallback);
	CAN_Init();
	J1939_init();
	InitUsart0();
	
	if (Button_GetCurrentButtonState(BUTTON_ID_B1) == StateLow)
		SetModePass();	
    
    while(1)
    { 
    	WDTCP_ = 0x00;    	
    	Timer_Main();	      
    }   
}
Beispiel #10
0
Datei: Cpu.c Projekt: ducis/HCS
/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S12XS256_80)
**
**     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 */
  /* PORTB: PB7=0,PB6=1,PB5=0,PB4=1,PB3=0,PB2=1,PB1=0,PB0=1 */
  setReg8(PORTB, 85);                   
  /* PUCR: PUPBE=0 */
  clrReg8Bits(PUCR, 2);                 
  /* DDRB: DDRB7=1,DDRB6=1,DDRB5=1,DDRB4=1,DDRB3=1,DDRB2=1,DDRB1=1,DDRB0=1 */
  setReg8(DDRB, 255);                   
  /* CRGINT: LOCKIE=0,SCMIE=0 */
  clrReg8Bits(CRGINT, 18);              
  /* VREGCTRL: LVIE=0 */
  clrReg8Bits(VREGCTRL, 2);             
  /* COPCTL: WCOP=0,RSBCK=0,WRTMASK=0,??=0,??=0,CR2=0,CR1=0,CR0=0 */
  setReg8(COPCTL, 0);                   
  /* DDR0AD0: DDR0AD07=1,DDR0AD06=1,DDR0AD05=1,DDR0AD04=1,DDR0AD03=1,DDR0AD02=1,DDR0AD01=1,DDR0AD00=1 */
  setReg8(DDR0AD0, 255);                
  /* DDRH: DDRH7=1,DDRH6=1,DDRH5=1,DDRH4=1,DDRH3=1,DDRH2=1,DDRH1=1,DDRH0=1 */
  setReg8(DDRH, 255);                   
  /* DDRJ: DDRJ1=1,DDRJ0=1 */
  setReg8Bits(DDRJ, 3);                 
  /* DDRK: DDRK7=1,DDRK5=1,DDRK4=1,DDRK3=1,DDRK2=1,DDRK1=1,DDRK0=1 */
  setReg8Bits(DDRK, 191);               
  /* DDRM: DDRM7=1,DDRM6=1 */
  setReg8Bits(DDRM, 192);               
  /* DDRP: DDRP6=1 */
  setReg8Bits(DDRP, 64);                
  /* DDRS: DDRS7=1,DDRS6=1,DDRS5=1,DDRS4=1 */
  setReg8Bits(DDRS, 240);               
  /* RDRIV: RDPE=0,RDPB=0,RDPA=0 */
  clrReg8Bits(RDRIV, 19);               
  /* RDRJ: RDRJ7=0,RDRJ6=0 */
  clrReg8Bits(RDRJ, 192);               
  /* RDRM: RDRM5=0,RDRM4=0,RDRM3=0,RDRM2=0,RDRM1=0,RDRM0=0 */
  clrReg8Bits(RDRM, 63);                
  /* RDRP: RDRP7=0,RDRP5=0,RDRP4=0,RDRP3=0,RDRP2=0,RDRP1=0,RDRP0=0 */
  clrReg8Bits(RDRP, 191);               
  /* RDRS: RDRS3=0,RDRS2=0,RDRS1=0,RDRS0=0 */
  clrReg8Bits(RDRS, 15);                
  /* RDRT: RDRT7=0,RDRT6=0,RDRT5=0,RDRT4=0,RDRT3=0,RDRT2=0,RDRT1=0,RDRT0=0 */
  setReg8(RDRT, 0);                     
  /* RDR1AD0: RDR1AD07=0,RDR1AD06=0,RDR1AD05=0,RDR1AD04=0,RDR1AD03=0,RDR1AD02=0,RDR1AD01=0,RDR1AD00=0 */
  setReg8(RDR1AD0, 0);                  
  /* IRQCR: IRQEN=0 */
  clrReg8Bits(IRQCR, 64);               
  /* ### MC9S12XS256_80 "Cpu" init code ... */
  /* ### ByteIO "Byte1" init code ... */
  Shadow_B = (byte)85;                 /* Initialize port "Byte1" shadow variable */
  asm {
    PSHA
    LDAA #0
    TFR A,CCRH
    PULA
  }
  __EI();                              /* Enable interrupts */
}
Beispiel #11
0
Datei: Cpu.c Projekt: ducis/HCS
/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S12XDT384_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)
{
  /* Initialization of RAM Protection (MMC module) */
  /* RAMXGU: ??=1,XGU6=1,XGU5=1,XGU4=1,XGU3=1,XGU2=1,XGU1=1,XGU0=1 */
  setReg8(RAMXGU, 255);                 
  /* RAMSHL: ??=1,SHL6=1,SHL5=1,SHL4=1,SHL3=1,SHL2=1,SHL1=1,SHL0=1 */
  setReg8(RAMSHL, 255);                 
  /* RAMSHU: ??=1,SHU6=1,SHU5=1,SHU4=1,SHU3=1,SHU2=1,SHU1=1,SHU0=1 */
  setReg8(RAMSHU, 255);                 
  /* RAMWPC: RWPE=0,??=0,??=0,??=0,??=0,??=0,AVIE=0,AVIF=0 */
  setReg8(RAMWPC, 0);                   
  /* Common initialization of the CPU registers */
  /* PORTA: PA0=1 */
  setReg8Bits(PORTA, 1);                
  /* PUCR: PUPAE=0 */
  clrReg8Bits(PUCR, 1);                 
  /* DDRA: DDRA0=1 */
  setReg8Bits(DDRA, 1);                 
  /* CRGINT: LOCKIE=0,SCMIE=0 */
  clrReg8Bits(CRGINT, 18);              
  /* VREGCTRL: LVIE=0 */
  clrReg8Bits(VREGCTRL, 2);             
  /* COPCTL: WCOP=0,RSBCK=0,WRTMASK=0,??=0,??=0,CR2=0,CR1=0,CR0=0 */
  setReg8(COPCTL, 0);                   
  /* RDRIV: RDPK=0,RDPE=0,RDPB=0,RDPA=0 */
  clrReg8Bits(RDRIV, 147);              
  /* RDR1AD1: RDR1AD115=0,RDR1AD114=0,RDR1AD113=0,RDR1AD112=0,RDR1AD111=0,RDR1AD110=0,RDR1AD19=0,RDR1AD18=0 */
  setReg8(RDR1AD1, 0);                  
  /* 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);                     
  /* RDR1AD0: RDR1AD07=0,RDR1AD06=0,RDR1AD05=0,RDR1AD04=0,RDR1AD03=0,RDR1AD02=0,RDR1AD01=0,RDR1AD00=0 */
  setReg8(RDR1AD0, 0);                  
  /* IRQCR: IRQEN=0 */
  clrReg8Bits(IRQCR, 64);               
  /* ### MC9S12XDT384_112 "Cpu" init code ... */
  /* ### BitIO "Bit1" init code ... */
  asm {
    PSHA
    LDAA #0
    TFR A,CCRH
    PULA
  }
  __EI();                              /* Enable interrupts */
}
Beispiel #12
0
//===========================================================================
//	OSC set
//===========================================================================
static void SetOSC(void){

	//Frequency Control Register 0 (FCON0) 	
	//	used to control the high-speed clock generation circuit and to select system clock.
		SYSC0  = 0;			// Used to select the frequency of the HSCLK => 00=8.192MHz.
		SYSC1  = 0;			//...
		OSCM1  = 1;			// 10 => Built-in PLL oscillation mode
		OSCM0  = 0;			//...
		
	// Frequency Control Register 1 (FCON1)
		ENOSC  = 1;			// 1=Enable High Speed Oscillator...
		SYSCLK = 1;			// Select System Clock: 1=HSCLK; 0=LSCLK 
		LPLL   = 1;			// 1=Enables the use of PLL oscillation - ADDED 4/30/2013

	__EI();					//INT enable
}
Beispiel #13
0
//удаление таймера 
void del_timer(TYPE_DATA_TIMER * tmr)
{
	BYTE cnt;
	cnt = COUNT_USER_TIMERS;
	while (cnt--)
	{				
		if (SystemTimers.timers[cnt]==tmr) // таймер найден
		{
			__DI();
			SystemTimers.timers[cnt] = 0;
			SystemTimers.count--;  
			__EI();
			return;	
		}
	}
}
Beispiel #14
0
//===========================================================================
//	OSC set
//===========================================================================
static void SetOSC(void){

	//FCON0: 			// xMHz PLL (3=1MHz; 2=2MHz; 1=4MHz; 0=8MHz)...
	SYSC0 = 0;			// Used to select the frequency of the HSCLK => 00=8.192MHz.
	SYSC1 = 0;

	OSCM1 = 1;			// 10 => Built-in PLL oscillation mode
	OSCM0 = 0;
   	
	ENOSC = 1;			//1=Enable High Speed Oscillator...MUST ENABLE before setting SYSTEM CLOCK!
	SYSCLK = 1;			//1=HSCLK; 0=LSCLK (MUST set ENOSC = 1 first) 

	LPLL = 1;			//1=Enables the use of PLL oscillation - ADDED 4/30/2013

	__EI();			//INT enable
}
Beispiel #15
0
void Operate_Max1329_ADC_Convert(BYTE Num, BYTE Mux, BYTE Gain, BYTE Bip)
{
	if(Num == 0xFF) SelectAll_DAC();
	else SelectSPI_DAC(Num);
	__DI();
	
	pak_spi_adc.bits.Mux	= Mux;
	pak_spi_adc.bits.Gain	= Gain;
	pak_spi_adc.bits.Bip	= Bip;
	pak_spi_adc.bits.start	= 1;
	
	Send_SIO(pak_spi_adc.data);
	stop_sio();
	__EI();
	UnSelectAll_DAC();
}
Beispiel #16
0
void Operate_Max1329_Reset(BYTE Num)
{
	if(Num == 0xFF) SelectAll_DAC();
	else SelectSPI_DAC(Num);
	__DI();
	
	pak_spi_rm.data = 0;
	pak_spi_rm.bits.RW	= WRITE_MODE_SPI;
	pak_spi_rm.bits.adr	= 0x1F;
	Send_SIO(pak_spi_rm.data);
		
	Send_SIO(0xFF);
	stop_sio();
	__EI();
	UnSelectAll_DAC();
}
Beispiel #17
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MC9S08JM60_64)
**
**     Description :
**         Initializes components 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 */
  /* PTGD: PTGD1=0,PTGD0=1 */
  clrSetReg8Bits(PTGD, 0x02U, 0x01U);   
  /* PTGPE: PTGPE1=0,PTGPE0=0 */
  clrReg8Bits(PTGPE, 0x03U);            
  /* PTGDD: PTGDD1=1,PTGDD0=1 */
  setReg8Bits(PTGDD, 0x03U);            
  /* PTASE: PTASE5=0,PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */
  clrReg8Bits(PTASE, 0x3FU);            
  /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */
  setReg8(PTBSE, 0x00U);                
  /* PTCSE: PTCSE6=0,PTCSE5=0,PTCSE4=0,PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */
  clrReg8Bits(PTCSE, 0x7FU);            
  /* PTDSE: PTDSE7=0,PTDSE6=0,PTDSE5=0,PTDSE4=0,PTDSE3=0,PTDSE2=0,PTDSE1=0,PTDSE0=0 */
  setReg8(PTDSE, 0x00U);                
  /* PTESE: PTESE7=0,PTESE6=0,PTESE5=0,PTESE4=0,PTESE3=0,PTESE2=0,PTESE1=0,PTESE0=0 */
  setReg8(PTESE, 0x00U);                
  /* PTFSE: PTFSE7=0,PTFSE6=0,PTFSE5=0,PTFSE4=0,PTFSE3=0,PTFSE2=0,PTFSE1=0,PTFSE0=0 */
  setReg8(PTFSE, 0x00U);                
  /* PTGSE: PTGSE5=0,PTGSE4=0,PTGSE3=0,PTGSE2=0,PTGSE1=0,PTGSE0=0 */
  clrReg8Bits(PTGSE, 0x3FU);            
  /* PTADS: ??=0,??=0,PTADS5=1,PTADS4=1,PTADS3=1,PTADS2=1,PTADS1=1,PTADS0=1 */
  setReg8(PTADS, 0x3FU);                
  /* PTBDS: PTBDS7=1,PTBDS6=1,PTBDS5=1,PTBDS4=1,PTBDS3=1,PTBDS2=1,PTBDS1=1,PTBDS0=1 */
  setReg8(PTBDS, 0xFFU);                
  /* PTCDS: ??=0,PTCDS6=1,PTCDS5=1,PTCDS4=1,PTCDS3=1,PTCDS2=1,PTCDS1=1,PTCDS0=1 */
  setReg8(PTCDS, 0x7FU);                
  /* PTDDS: PTDDS7=1,PTDDS6=1,PTDDS5=1,PTDDS4=1,PTDDS3=1,PTDDS2=1,PTDDS1=1,PTDDS0=1 */
  setReg8(PTDDS, 0xFFU);                
  /* PTEDS: PTEDS7=1,PTEDS6=1,PTEDS5=1,PTEDS4=1,PTEDS3=1,PTEDS2=1,PTEDS1=1,PTEDS0=1 */
  setReg8(PTEDS, 0xFFU);                
  /* PTFDS: PTFDS7=1,PTFDS6=1,PTFDS5=1,PTFDS4=1,PTFDS3=1,PTFDS2=1,PTFDS1=1,PTFDS0=1 */
  setReg8(PTFDS, 0xFFU);                
  /* PTGDS: ??=0,??=0,PTGDS5=1,PTGDS4=1,PTGDS3=1,PTGDS2=1,PTGDS1=1,PTGDS0=1 */
  setReg8(PTGDS, 0x3FU);                
  /* ### Shared modules init code ... */
  /* ### BitIO "powerLED" init code ... */
  Shadow_PTG &= 0xFDU;                 /* Initialize pin shadow variable bit */
  /* ### BitIO "statusLED" init code ... */
  Shadow_PTG |= (byte)0x01U;           /* Initialize pin shadow variable bit */
  /* ### TimerInt "sampleTimer" init code ... */
  sampleTimer_Init();
  __EI();                              /* Enable interrupts */
}
Beispiel #18
0
//===================================================================================
void DriverRVV()
{
	__DI();
	Rvv.Error&=0x7F;
	Rvv.Error|=RIN2<<7;
	__EI();
	if(Rvv.newDn!=Rvv.Dn)
	{
		Rvv.Dn=Rvv.newDn;
		WriteBlock(5,Rvv.Dn);
		WriteBlock(6,Rvv.Dn>>4);
		if((ReadBlock(5)!=(Rvv.Dn&0xF)) && ((ReadBlock(6)!=((Rvv.Dn>>4)&0xF))))
		{
			Rvv.Error|=0x1;
			WriteBlock(6,0x8|(Rvv.Dn>>4));
		}
		else Rvv.Error&=0xFE;
Beispiel #19
0
void Operate_Max1329_DAC_Write_Mask(WORD Mask, BYTE ch, WORD data)
{

	SelectMask_DAC(Mask);
	__DI();
					
	pak_spi_dac.bits.ch 	= ch;
	pak_spi_dac.bits.d1 	= 1;
	pak_spi_dac.bits.start	= 0;
	pak_spi_dac.bits.dac 	= data;
	pak_spi_dac.bits.rw 	= WRITE_MODE_SPI;
	Send_SIO(pak_spi_dac.data[1]);
	Send_SIO(pak_spi_dac.data[0]);
	stop_sio();
	__EI();
	UnSelectAll_DAC();
}
Beispiel #20
0
//========================================================================
//========================================================================
void Operate_Max1329_DAC_Write(BYTE Num, BYTE ch, WORD data)
{
	if(Num == 0xFF) SelectAll_DAC();
	else SelectSPI_DAC(Num);
	__DI();
					
	pak_spi_dac.bits.ch 	= ch;
	pak_spi_dac.bits.d1 	= 1;
	pak_spi_dac.bits.start	= 0;
	pak_spi_dac.bits.dac 	= data;
	pak_spi_dac.bits.rw 	= WRITE_MODE_SPI;
	Send_SIO(pak_spi_dac.data[1]);
	Send_SIO(pak_spi_dac.data[0]);
	stop_sio();
	__EI();
	UnSelectAll_DAC();
}
Beispiel #21
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MC9S08SH8_20)
**
**     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 */
  /* PTCD: PTCD0=0 */
  clrReg8Bits(PTCD, 0x01);              
  /* PTCPE: PTCPE0=0 */
  clrReg8Bits(PTCPE, 0x01);             
  /* PTCDD: PTCDD0=1 */
  setReg8Bits(PTCDD, 0x01);             
  /* PTAPE: PTAPE5=0,PTAPE0=0 */
  clrReg8Bits(PTAPE, 0x21);             
  /* PTADD: PTADD5=0,PTADD0=0 */
  clrReg8Bits(PTADD, 0x21);             
  /* PTBPE: PTBPE6=0 */
  clrReg8Bits(PTBPE, 0x40);             
  /* PTBDD: PTBDD6=0 */
  clrReg8Bits(PTBDD, 0x40);             
  /* PTASE: PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */
  clrReg8Bits(PTASE, 0x1F);             
  /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */
  setReg8(PTBSE, 0x00);                 
  /* PTCSE: PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */
  clrReg8Bits(PTCSE, 0x0F);             
  /* PTADS: ??=0,??=0,??=0,PTADS4=1,PTADS3=1,PTADS2=1,PTADS1=1,PTADS0=1 */
  setReg8(PTADS, 0x1F);                 
  /* PTBDS: PTBDS7=1,PTBDS6=1,PTBDS5=1,PTBDS4=1,PTBDS3=1,PTBDS2=1,PTBDS1=1,PTBDS0=1 */
  setReg8(PTBDS, 0xFF);                 
  /* PTCDS: ??=0,??=0,??=0,??=0,PTCDS3=1,PTCDS2=1,PTCDS1=1,PTCDS0=1 */
  setReg8(PTCDS, 0x0F);                 
  /* ### Shared modules init code ... */
  /* ### BitIO "Bit1" init code ... */
  /* ### Timer capture encapsulation "Cap1" init code ... */
  Cap1_Init();
  /* ### TimerInt "TI1" init code ... */
  TI1_Init();
  /* ### External interrupt "EInt1" init code ... */
  /* IRQSC: ??=0,IRQPDD=1,IRQEDG=0,IRQPE=1,IRQF=0,IRQACK=0,IRQIE=0,IRQMOD=1 */
  IRQSC = 0x51;
  IRQSC_IRQACK = 0x01;
  IRQSC_IRQIE = 0x01;
  /* ### BitIO "Bit2" init code ... */
  /* ### Init_FLASH "FLASH1" init code ... */
  FLASH1_Init();
  __EI();                              /* Enable interrupts */
}
Beispiel #22
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MC9S08SC4_16)
**
**     Description :
**         Initializes components 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)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /* Common initialization of the CPU registers */
  /* PTBD: PTBD7=0,PTBD6=0,PTBD5=0,PTBD4=0 */
  clrReg8Bits(PTBD, 0xF0U);             
  /* PTBPE: PTBPE7=0,PTBPE6=0,PTBPE5=0,PTBPE4=0,PTBPE3=0,PTBPE2=0,PTBPE1=0,PTBPE0=0 */
  setReg8(PTBPE, 0x00U);                
  /* PTBDD: PTBDD7=1,PTBDD6=1,PTBDD5=1,PTBDD4=1,PTBDD3=0,PTBDD2=0,PTBDD1=0,PTBDD0=0 */
  setReg8(PTBDD, 0xF0U);                
  /* PTAD: PTAD3=0 */
  clrReg8Bits(PTAD, 0x08U);             
  /* PTAPE: PTAPE3=0,PTAPE1=0 */
  clrReg8Bits(PTAPE, 0x0AU);            
  /* PTADD: PTADD3=1,PTADD1=0 */
  clrSetReg8Bits(PTADD, 0x02U, 0x08U);  
  /* PTASE: PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */
  clrReg8Bits(PTASE, 0x0FU);            
  /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */
  setReg8(PTBSE, 0x00U);                
  /* PTADS: ??=0,??=0,??=0,??=0,PTADS3=0,PTADS2=1,PTADS1=1,PTADS0=1 */
  setReg8(PTADS, 0x07U);                
  /* PTBDS: PTBDS7=0,PTBDS6=0,PTBDS5=0,PTBDS4=0,PTBDS3=0,PTBDS2=0,PTBDS1=0,PTBDS0=0 */
  setReg8(PTBDS, 0x00U);                
  /* ### Shared modules init code ... */
  /* ### BitsIO "Signal_In" init code ... */
  /* ### BitsIO "Lever_Pos_MPND" init code ... */
  /* ### BitIO "Lever_Pos_R" init code ... */
  /* ### BitIO "AD1" init code ... */
  /* ### Timer capture encapsulation "PWM_In" init code ... */
  PWM_In_Init();
  /* ### TimerInt "PWM_Timer" init code ... */
  PWM_Timer_Init();
  /* ###  WatchDog "WDT" init code ... */
  /* SRS: POR=0,PIN=1,COP=0,ILOP=1,ILAD=0,??=1,LVD=0,??=1 */
  setReg8(SRS, 0x55U);                  
  /* SRS: POR=1,PIN=0,COP=1,ILOP=0,ILAD=1,??=0,LVD=1,??=0 */
  setReg8(SRS, 0xAAU);                  
  CCR_lock = (byte)0;
  __EI();                              /* Enable interrupts */
  /* TPM2SC: TOIE=0 */
  clrReg8Bits(TPM2SC, 0x40U);          /* Disable overflow interrupt */ 
}
Beispiel #23
0
BYTE uart0_get (void)
{
    BYTE d;
    int i;


    do;
    while (!RxFifo.ct);

    i = RxFifo.ri;
    d = RxFifo.buff[i++];
    RxFifo.ri = i % BUFFER_SIZE;
    __DI();
    RxFifo.ct--;
    __EI();

    return d;
}
Beispiel #24
0
/* ===================================================================*/
void UserInit(void)
{
    UserDataInit();     /* Initialize user data. */
#if DEBUG
    printf("| -UserDataInit finished.\n");
    printf("|-+OnChipInit begins...\n");
#endif
    __DI();
    OnChipInit();       /* Initialize on-chip devices. */
    __EI();
#if DEBUG
    printf("| -OnChipInit finished.\n");
    printf("|-+PeripheralInit begins...\n");
#endif
    PeripheralInit();   /* Initialize peripheral devices. */
#if DEBUG
    printf("| -PeripheralInit finished.\n");
#endif
}
Beispiel #25
0
void uart0_put (BYTE d)
{
    int i;


    do;
    while (TxFifo.ct >= BUFFER_SIZE);

    i = TxFifo.wi;
    TxFifo.buff[i++] = d;
    TxFifo.wi = i % BUFFER_SIZE;
    __DI();
    TxFifo.ct++;
    if (!TxRun) {
        TxRun = 1;
        UA0TIF = 1;
    }
    __EI();
}
Beispiel #26
0
//---------------------------------------------------------------------------------------------------------
// Процедура подавление дребезга входов DIn
// Вызывается для каждого модуля НДД
//addr		- адрес модуля
//inputs	- считанное состояние НДД
//time		- Время подавления дребезга
void debounce_Din(unsigned char addr, unsigned char inputs, unsigned short time)
{
	unsigned char i;									// счетчик
	unsigned char ch_cnt;								// колличество входов у данного
	unsigned char pr,tmp,bit;							// временные переменные

__DI();

	pr=Ndd.pr_data[addr];
	
	tmp = inputs ^ pr;									// в tmp - изменения на входах
	if (time==0) time=1;
	for (i=0;i<8;i++)
	{
		bit = 1<<i;										// определение текущего входа
		if (tmp & bit)
		{												// состояние входа изменилось - сброс счетчика
			Ndd.counters[addr][i]=0;
			Ndd.counters_dr[addr][i]++;	
			if(Ndd.counters_dr[addr][i]>=time)			//Входной сигнал не устанавливается в устойчивое состояние
			{
				Ndd.counters_dr[addr][i]=time;
				Ndd.drebezg[addr]&=~bit;				//
				Ndd.drebezg[addr]|=bit;					//Запись сигнала у которого дребезг
			}
			else	Ndd.drebezg[addr]&=~bit;
		} 
		else
		 {												// состояние входа не изменилось - инкремент
			Ndd.counters_dr[addr][i]=0;
			Ndd.counters[addr][i]++;					// счетчика
			if (Ndd.counters[addr][i]>=time-1)
			{											// состояние входа установилось
				Ndd.state[addr]&=~bit;					// запись состояния входа
				Ndd.state[addr]|=(inputs & bit);
				Ndd.counters[addr][i]--;				// декремент счетчика
			}
		}
	}
	Ndd.pr_data[addr] = inputs;							// сохранение текущих значений как предыдущих
__EI();
}
Beispiel #27
0
//=============================================================================
void Driver_FSU22()
{
	BYTE i;
	__DI();
	
	i=ADDR;	
	Fsu22.Info.bits.Addr	=i;
	if(i!=ADDR_NODE)
	{
		setState(Initialisation);
		ADDR_NODE			=ADDR;
	}
	Fsu22.Info.bits.Mode=MODE;
	//**************************************************
	Fsu22.Info.bits.F1=PG_F1;
	//**************************************************
	
	if(Fsu22.Prin.word!=Fsu22.State.word)	//Устанавливаем новые команды
	{
		Fsu22.State.word=Fsu22.Prin.word;
		
		S1=Fsu22.State.bits.O1;
		S2=Fsu22.State.bits.O2;
		S3=Fsu22.State.bits.O3;
		S4=Fsu22.State.bits.O4;
		S5=Fsu22.State.bits.O5;
		S6=Fsu22.State.bits.O6;
		
		S7=Fsu22.State.bits.O7;
		S8=Fsu22.State.bits.O8;
		S9=Fsu22.State.bits.O9;
		S10=Fsu22.State.bits.O10;
		S11=Fsu22.State.bits.O11;
		S12=Fsu22.State.bits.O12;
		
		Fsu22.Timer_Test=0;
	}
	__EI();
	//**************************************************
	TestOutput();	
	//**************************************************
}
Beispiel #28
0
void Operate_Max1329_RegMode_Mask(WORD Mask, BYTE Adr, BYTE Count)// только запись
{
	BYTE i;
	
	SelectMask_DAC(Mask);
	
	__DI();
	
	pak_spi_rm.data = 0;
	pak_spi_rm.bits.RW	= WRITE_MODE_SPI;;
	pak_spi_rm.bits.adr	= Adr;
	Send_SIO(pak_spi_rm.data);
		
		for(i=0;i<Count;i++)
			Send_SIO(Spi_Buf_Out[i]);
		stop_sio();
	
	__EI();
	UnSelectAll_DAC();
}
Beispiel #29
0
void board_init() {

  DisableWatchdog;
  //at the beginning, we source our uC off the internal clock (8MhZ), whihc is innacurate
  //once set up, we will use spi com. to the radio to use the 16MHz radio crystal as a time source
  ICGC1 = 0x28;
  ICGC2 = 0x61; //page 14-16 of data sheet N=16 R=2 ~17773714.3Mhz clock, 8886857.14 Mhz bus speed
 

   // initialize bsp modules
   leds_init();
   //uart_init();
   spi_init();
   radio_init();
   //radiotimer_init();
  
   
   __EI();//enable interrupts;
   
   
}
Beispiel #30
0
WORD Operate_Max1329_DAC_Read(BYTE Num, BYTE ch)
{
	WORD d;
	
	if(Num == 0xFF) SelectAll_DAC();
	else SelectSPI_DAC(Num);
	__DI();
	
	pak_spi_dac.bits.ch 	= ch;
	pak_spi_dac.bits.d1 	= 1;
	pak_spi_dac.bits.start	= 0;
	pak_spi_dac.bits.dac 	= 0;
	pak_spi_dac.bits.rw 	= READ_MODE_SPI;
	d=Send_SIO(pak_spi_dac.data[1]);
	d = (d&0xF)<<8;
	d |= Send_SIO(pak_spi_dac.data[0]);
	stop_sio();
	__EI();
	UnSelectAll_DAC();
	return d;
}