Esempio n. 1
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 */
}
Esempio n. 2
0
File: Cpu.c Progetto: 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 */
}
/*
** ===================================================================
**     Method      :  led_PutVal (component BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void led_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTBD, 0x20);           /* PTBD5=0x01 */
  } else { /* !Val */
    clrReg8Bits(PTBD, 0x20);           /* PTBD5=0x00 */
  } /* !Val */
}
Esempio n. 4
0
File: Bit2.c Progetto: ducis/HCS
/*
** ===================================================================
**     Method      :  Bit2_PutVal (bean BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void Bit2_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PORTB, 1);             /* PB0=1 */
  } else { /* !Val */
    clrReg8Bits(PORTB, 1);             /* PB0=0 */
  } /* !Val */
}
/*
** ===================================================================
**     Method      :  ACKNOWLEDGE_LED_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void ACKNOWLEDGE_LED_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTDD, 0x40U);          /* PTDD6=0x01U */
  } else { /* !Val */
    clrReg8Bits(PTDD, 0x40U);          /* PTDD6=0x00U */
  } /* !Val */
}
/*
** ===================================================================
**     Method      :  SquareWave_PutVal (component BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void SquareWave_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTED, 0x40U);          /* PTED6=0x01U */
  } else { /* !Val */
    clrReg8Bits(PTED, 0x40U);          /* PTED6=0x00U */
  } /* !Val */
}
Esempio n. 7
0
/*
** ===================================================================
**     Method      :  Bit1_PutVal (component BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void Bit1_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTCD, 0x01);           /* PTCD0=0x01 */
  } else { /* !Val */
    clrReg8Bits(PTCD, 0x01);           /* PTCD0=0x00 */
  } /* !Val */
}
Esempio n. 8
0
/*
** ===================================================================
**     Method      :  O2_PutVal (bean BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void O2_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTP, 2);               /* PTP1=1 */
  } else { /* !Val */
    clrReg8Bits(PTP, 2);               /* PTP1=0 */
  } /* !Val */
}
Esempio n. 9
0
/*
** ===================================================================
**     Method      :  Ref2_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void Ref2_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTBD, 0x01U);          /* PTBD0=0x01U */
  } else { /* !Val */
    clrReg8Bits(PTBD, 0x01U);          /* PTBD0=0x00U */
  } /* !Val */
}
Esempio n. 10
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 */
}
Esempio n. 11
0
File: Bit8.c Progetto: ducis/HCS
/*
** ===================================================================
**     Method      :  Bit8_PutVal (bean BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void Bit8_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PORTB, 8);             /* PB3=1 */
  } else { /* !Val */
    clrReg8Bits(PORTB, 8);             /* PB3=0 */
  } /* !Val */
}
Esempio n. 12
0
/*
** ===================================================================
**     Method      :  LED_RUN_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void LED_RUN_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PORT_PTAD, 0x01U);     /*  */
  } else { /* !Val */
    clrReg8Bits(PORT_PTAD, 0x01U);     /*  */
  } /* !Val */
}
Esempio n. 13
0
/*
** ===================================================================
**     Method      :  O6_PutVal (bean BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void O6_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTP, 32);              /* PTP5=1 */
  } else { /* !Val */ 
    clrReg8Bits(PTP, 32);              /* PTP5=0 */
  } /* !Val */ 
}
Esempio n. 14
0
/*
** ===================================================================
**     Method      :  LedG_PutVal (component BitIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void LedG_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTBD, 0x04);           /* PTBD2=0x01 */
  } else { /* !Val */
    clrReg8Bits(PTBD, 0x04);           /* PTBD2=0x00 */
  } /* !Val */
}
Esempio n. 15
0
/*
** ===================================================================
**     Method      :  M_1_Disable (component PWM)
**     Description :
**         This method disables the component - it stops the signal
**         generation and events calling. When the timer is disabled,
**         it is possible to call <ClrValue> and <SetValue> methods.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte M_1_Disable(void)
{
  /* TPM1SC: TOIE=0 */
  clrReg8Bits(TPM1SC, 0x40U);          /* Disable Timer Overflow Interrupt */ 
  /* TPM1C1SC: CH1F=0,CH1IE=0,MS1B=0,MS1A=0,ELS1B=0,ELS1A=0,??=0,??=0 */
  setReg8(TPM1C1SC, 0x00U);            /* Disable output signal */ 
  return ERR_OK;                       /* OK */
}
Esempio n. 16
0
/*
** ===================================================================
**     Method      :  En4_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void En4_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTFD, 0x80U);          /* PTFD7=0x01U */
  } else { /* !Val */
    clrReg8Bits(PTFD, 0x80U);          /* PTFD7=0x00U */
  } /* !Val */
}
Esempio n. 17
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 */ 
}
Esempio n. 18
0
/*
** ===================================================================
**     Method      :  statusLED_SetDir (component BitIO)
**     Description :
**         This method sets direction of the component.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void statusLED_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTGD, (getReg8(PTGD) & (byte)(~(byte)0x01U)) | (Shadow_PTG & 0x01U)); /* PTGD0=Shadow_PTG[bit 0] */
    setReg8Bits(PTGDD, 0x01U);         /* PTGDD0=0x01U */
  } else { /* !Dir */
    clrReg8Bits(PTGDD, 0x01U);         /* PTGDD0=0x00U */
  } /* !Dir */
}
Esempio n. 19
0
/*
** ===================================================================
**     Method      :  LedB_SetDir (component BitIO)
**
**     Description :
**         This method sets direction of the bean.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void LedB_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTBD, (getReg8(PTBD) & (~0x08)) | (Shadow_PTB & 0x08)); /* PTBD3=Shadow_PTB[bit 3] */
    setReg8Bits(PTBDD, 0x08);          /* PTBDD3=0x01 */
  } else { /* !Dir */
    clrReg8Bits(PTBDD, 0x08);          /* PTBDD3=0x00 */
  } /* !Dir */
}
Esempio n. 20
0
/*
** ===================================================================
**     Method      :  powerLED_SetDir (component BitIO)
**     Description :
**         This method sets direction of the component.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void powerLED_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTGD, (getReg8(PTGD) & (byte)(~(byte)0x02U)) | (Shadow_PTG & 0x02U)); /* PTGD1=Shadow_PTG[bit 1] */
    setReg8Bits(PTGDD, 0x02U);         /* PTGDD1=0x01U */
  } else { /* !Dir */
    clrReg8Bits(PTGDD, 0x02U);         /* PTGDD1=0x00U */
  } /* !Dir */
}
Esempio n. 21
0
File: Byte1.c Progetto: ducis/HCS
/*
** ===================================================================
**     Method      :  Byte1_PutBit (bean ByteIO)
**
**     Description :
**         This method writes the new value to the specified bit
**         of the output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit (0 to 7)
**         Val        - New value of the bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void Byte1_PutBit(byte Bit, bool Val)
{
  byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - put bit mask */
  if (Val) {
    setReg8Bits(PORTB, Mask);          /* [bit Bit]=1 */
  } else { /* !Val */
    clrReg8Bits(PORTB, Mask);          /* [bit Bit]=0 */
  } /* !Val */
}
Esempio n. 22
0
/*
** ===================================================================
**     Method      :  statusLED_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**           a) direction = Input  : sets the new output value;
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes the value to the
**                                   appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void statusLED_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTGD, 0x01U);          /* PTGD0=0x01U */
    Shadow_PTG |= 0x01U;               /* Set-up shadow variable */
  } else { /* !Val */
    clrReg8Bits(PTGD, 0x01U);          /* PTGD0=0x00U */
    Shadow_PTG &= 0xFEU;               /* Set-up shadow variable */
  } /* !Val */
}
Esempio n. 23
0
/*
** ===================================================================
**     Method      :  powerLED_PutVal (component BitIO)
**     Description :
**         This method writes the new output value.
**           a) direction = Input  : sets the new output value;
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes the value to the
**                                   appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void powerLED_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTGD, 0x02U);          /* PTGD1=0x01U */
    Shadow_PTG |= 0x02U;               /* Set-up shadow variable */
  } else { /* !Val */
    clrReg8Bits(PTGD, 0x02U);          /* PTGD1=0x00U */
    Shadow_PTG &= 0xFDU;               /* Set-up shadow variable */
  } /* !Val */
}
Esempio n. 24
0
/*
** ===================================================================
**     Method      :  HWEnDi (component TimerInt)
**
**     Description :
**         Enables or disables the peripheral(s) associated with the 
**         component. The method is called automatically as a part of the 
**         Enable and Disable methods and several internal methods.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void HWEnDi(void)
{
  if (EnUser) {
    /* RTCSC: RTIF=1,RTCLKS=2,RTIE=1,RTCPS=8 */
    setReg8(RTCSC, 0xD8U);             /* Run RTC (select clock source; set frequency and enable interrupt) */ 
  } else {
    /* RTCSC: RTCPS=0 */
    clrReg8Bits(RTCSC, 0x0FU);         /* Stop counter */ 
  }
}
Esempio n. 25
0
/*
** ===================================================================
**     Method      :  LedB_PutVal (component BitIO)
**
**     Description :
**         This method writes the new output value.
**           a) direction = Input  : sets the new output value;
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes the value to the
**                                   appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val             - Output value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)
**     Returns     : Nothing
** ===================================================================
*/
void LedB_PutVal(bool Val)
{
  if (Val) {
    setReg8Bits(PTBD, 0x08);           /* PTBD3=0x01 */
    Shadow_PTB |= (byte)0x08;          /* Set-up shadow variable */
  } else { /* !Val */
    clrReg8Bits(PTBD, 0x08);           /* PTBD3=0x00 */
    Shadow_PTB &= (byte)~0x08;         /* Set-up shadow variable */
  } /* !Val */
}
Esempio n. 26
0
File: Byte1.c Progetto: ducis/HCS
/*
** ===================================================================
**     Method      :  Byte1_PutBit (bean ByteIO)
**
**     Description :
**         This method writes the new value to the specified bit
**         of the output value.
**           a) direction = Input  : sets the value of the specified
**                                   bit; this operation will be
**                                   shown on output after the
**                                   direction has been switched to
**                                   output (SetDir(TRUE);)
**           b) direction = Output : directly writes the value of the
**                                   bit to the appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit (0 to 7)
**         Val        - New value of the bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void Byte1_PutBit(byte Bit, bool Val)
{
  byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - put bit mask */
  if (Val) {
    setReg8Bits(PORTB, Mask);          /* [bit Bit]=1 */
    Shadow_B |= Mask;                  /* Set appropriate bit in shadow variable */
  } else { /* !Val */
    clrReg8Bits(PORTB, Mask);          /* [bit Bit]=0 */
    Shadow_B &= (byte)~Mask;           /* Clear appropriate bit in shadow variable */
  } /* !Val */
}
Esempio n. 27
0
void _EntryPoint(void)
{
  /* ### MC9S08PA16_32 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* WDOG_CNT: CNT=0xC520 */
  setReg16(WDOG_CNT, 0xC520U);         /* First part of the WDG unlock sequence */ 
  /* WDOG_CNT: CNT=0xD928 */
  setReg16(WDOG_CNT, 0xD928U);         /* Second part of the WDG unlock sequence */ 
  /*  Initialization of Init_WDOG */
  /* WDOG_CS1: EN=1,INT=0,UPDATE=1,TST=0,DBG=0,WAIT=1,STOP=1 */
  setReg8(WDOG_CS1, 0xA3U);             
  /* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=1,??=0,??=0,CLK=0 */
  setReg8(WDOG_CS2, 0x10U);             
  /* WDOG_TOVAL: TOVAL=0xF800 */
  setReg16(WDOG_TOVAL, 0xF800U);        
  /* Common initialization of the write once registers */
  /* SYS_SOPT1: SCI0PS=0,BKGDPE=1,RSTPE=1,FWAKE=0,STOPE=0 */
  clrSetReg8Bits(SYS_SOPT1, 0x83U, 0x0CU); 
  /* PMC_SPMSC1: LVWIE=0,LVDRE=1,LVDSE=1,LVDE=1,BGBDS=0,BGBE=0 */
  clrSetReg8Bits(PMC_SPMSC1, 0x23U, 0x1CU); 
  /* PMC_SPMSC2: LVDV=0,LVWV=0 */
  clrReg8Bits(PMC_SPMSC2, 0x70U);       
  /*  System clock initialization */
  /*lint -save  -e923 Disable MISRA rule (11.3) checking. */
  if (*(uint8_t*)0xFF6FU != 0xFFU) {   /* Test if the device trim value is stored on the specified address */
    ICS_C3 = *(uint8_t*)0xFF6FU;       /* Initialize ICS_C3 register from a non volatile memory */
    ICS_C4 = (uint8_t)((*(uint8_t*)0xFF6EU) & (uint8_t)0x01U); /* Initialize ICS_C4 register from a non volatile memory */
  }
  /*lint -restore Enable MISRA rule (11.3) checking. */
  /* ICS_C1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
  setReg8(ICS_C1, 0x06U);              /* Initialization of the ICS control register 1 */ 
  /* ICS_C2: BDIV=1,LP=0,??=0,??=0,??=0,??=0 */
  setReg8(ICS_C2, 0x20U);              /* Initialization of the ICS control register 2 */ 
  /* ICS_C4: LOLIE=0,CME=0 */
  clrReg8Bits(ICS_C4, 0xA0U);           

  /*** End of PE initialization code after reset ***/
  /*lint -save  -e950 Disable MISRA rule (1.1) checking. */
  __asm   jmp _Startup ;               /* Jump to C startup code */
  /*lint -restore Enable MISRA rule (1.1) checking. */
}
Esempio n. 28
0
void __initialize_hardware(void)
{

  /*** !!! Here you can place your own code using property "User code before PE initialization" on the build options tab of the CPU component. !!! ***/

  /* ### MCF51AC256A_80 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* Common initialization of the write once registers */
  /* SOPT: COPE=0,COPT=1,STOPE=0,WAITE=1,??=0,??=0,??=1,??=1 */
  setReg8(SOPT, 0x53U);                 
  /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1,??=0,BGBE=0 */
  setReg8(SPMSC1, 0x1CU);               
  /* SPMSC2: LVWF=0,LVWACK=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,??=0,PPDC=0 */
  setReg8(SPMSC2, 0x00U);               
  /* SMCLK: MPE=0,MCSEL=0 */
  clrReg8Bits(SMCLK, 0x17U);            
  /* Initialization of CPU registers */
  /*lint -save  -e950 Disable MISRA rule (1.1) checking. */
  asm {
    /* VBR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,ADDRESS=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
    clr.l d0
    movec d0,VBR
    /* CPUCR: ARD=0,IRD=0,IAE=0,IME=0,BWD=0,??=0,FSD=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
    clr.l d0
    movec d0,CPUCR
  }
  /*lint -restore Enable MISRA rule (1.1) checking. */
  /*  System clock initialization */
  /*lint -save  -e923 Disable MISRA rule (11.3) checking. */
  if (*(unsigned char*)0x03FFU != 0xFFU) { /* Test if the device trim value is stored on the specified address */
    MCGTRM = *(unsigned char*)0x03FFU; /* Initialize MCGTRM register from a non volatile memory */
    MCGSC = *(unsigned char*)0x03FEU;  /* Initialize MCGSC register from a non volatile memory */
  }
  /*lint -restore Enable MISRA rule (11.3) checking. */
  /* MCGC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */
  setReg8(MCGC2, 0x00U);               /* Set MCGC2 register */ 
  /* MCGC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
  setReg8(MCGC1, 0x06U);               /* Set MCGC1 register */ 
  /* MCGC3: LOLIE=0,PLLS=0,CME=0,DIV32=0,VDIV=1 */
  setReg8(MCGC3, 0x01U);               /* Set MCGC3 register */ 
  /* MCGC4: ??=0,??=0,DMX32=1,??=0,??=0,??=0,DRST_DRS=2 */
  setReg8(MCGC4, 0x22U);               /* Set MCGC4 register */ 
  while(MCGSC_LOCK == 0U) {            /* Wait until FLL is locked */
  }
  

  /*** End of PE initialization code after reset ***/

  /*** !!! Here you can place your own code using property "User code after PE initialization" on the build options tab of the CPU component. !!! ***/

}
Esempio n. 29
0
void __initialize_hardware(void)
{

    /*** !!! Here you can place your own code using property "User code before PE initialization" on the build options tab of the CPU component. !!! ***/

    /* ### MCF51QE128_64 "Cpu" init code ... */
    /*  PE initialization code after reset */
    /* Common initialization of the write once registers */
    /* SOPT1: COPE=0,COPT=1,STOPE=0,WAITE=1,??=0,RSTOPE=0,BKGDPE=1,RSTPE=1 */
    setReg8(SOPT1, 0x53U);
    /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=0,??=0,BGBE=0 */
    setReg8(SPMSC1, 0x18U);
    /* SPMSC2: LPR=0,LPRS=0,LPWUI=0,??=0,PPDF=0,PPDACK=0,PPDE=1,PPDC=0 */
    setReg8(SPMSC2, 0x02U);
    /* SPMSC3: LVDV=0,LVWV=0,LVWIE=0 */
    clrReg8Bits(SPMSC3, 0x38U);
    /* Initialization of CPU registers */
    /*lint -save  -e950 Disable MISRA rule (1.1) checking. */
    asm {
        /* VBR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,ADDRESS=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
        clr.l d0
        movec d0,VBR
        /* CPUCR: ARD=0,IRD=0,IAE=0,IME=0,BWD=0,??=0,FSD=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
        clr.l d0
        movec d0,CPUCR
    }
    /*lint -restore Enable MISRA rule (1.1) checking. */
    /*  System clock initialization */
    /*lint -save  -e923 Disable MISRA rule (11.3) checking. */
    if (*(unsigned char*)0x03FFU != 0xFFU) { /* Test if the device trim value is stored on the specified address */
        ICSTRM = *(unsigned char*)0x03FFU; /* Initialize ICSTRM register from a non volatile memory */
        ICSSC = (unsigned char)((*(unsigned char*)0x03FEU) & (unsigned char)0x01U); /* Initialize ICSSC register from a non volatile memory */
    }
    /*lint -restore Enable MISRA rule (11.3) checking. */
    /* ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
    setReg8(ICSC1, 0x06U);               /* Initialization of the ICS control register 1 */
    /* ICSC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */
    setReg8(ICSC2, 0x00U);               /* Initialization of the ICS control register 2 */
    while(ICSSC_IREFST == 0U) {          /* Wait until the source of reference clock is internal clock */
    }
    /* ICSSC: DRST_DRS=2,DMX32=0 */
    clrSetReg8Bits(ICSSC, 0x60U, 0x80U); /* Initialization of the ICS status and control */
    while((ICSSC & 0xC0U) != 0x80U) {    /* Wait until the FLL switches to High range DCO mode */
    }

    /*** End of PE initialization code after reset ***/

    /*** !!! Here you can place your own code using property "User code after PE initialization" on the build options tab of the CPU component. !!! ***/

}
Esempio n. 30
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 */
}