Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** ###################################################################
- ** Filename : Events.c
- ** Project : Project_9
- ** Processor : MC9S12C128CFU16
- ** Component : Events
- ** Version : Driver 01.04
- ** Compiler : CodeWarrior HC12 C Compiler
- ** Date/Time : 12/07/2018, 15:09
- ** Abstract :
- ** This is user's event module.
- ** Put your event handler code here.
- ** Settings :
- ** Contents :
- ** No public methods
- **
- ** ###################################################################*/
- /* MODULE Events */
- #include "Cpu.h"
- #include "Events.h"
- /* User includes (#include below this line is not maintained by Processor Expert) */
- #pragma CODE_SEG DEFAULT
- /*
- ** ===================================================================
- ** Event : AD1_OnEnd (module Events)
- **
- ** Component : AD1 [ADC]
- ** Description :
- ** This event is called after the measurement (which consists
- ** of <1 or more conversions>) is/are finished.
- ** The event is available only when the <Interrupt
- ** service/event> property is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- unsigned int d=0,aux,aux1,acc=0,fr=0,acionador,acionador2; //aux global de comparação
- void AD1_OnEnd(void)
- {
- /* Write your code here ... */
- unsigned int i;
- aux=aux1;
- AD1_GetChanValue16(0x00,&aux1);
- if(d>10000)
- {
- LED1_SetVal();
- LED2_SetVal();
- LED3_SetVal();
- }
- if(d>8000&&d<10000)
- {
- LED1_ClrVal();
- LED2_SetVal();
- LED3_SetVal();
- }
- if(d>6000&&d<8000)
- {
- LED1_ClrVal();
- LED2_ClrVal();
- LED3_SetVal();
- }
- if(d<6000)
- {
- LED1_ClrVal();
- LED2_ClrVal();
- LED3_ClrVal();
- }
- if(aux1<6000)
- aux1=5500;
- if(aux1>10000)
- aux1=11500;
- d = acc + aux1 - fr;
- //**********SENSOR DE APROXIMAÇÃO************
- for(i=0;i<1000;i++){
- if(aux>aux1)
- LED4_ClrVal();
- else
- LED4_SetVal();
- }
- }
- /*
- ** ===================================================================
- ** Event : TI1_OnInterrupt (module Events)
- **
- ** Component : TI1 [TimerInt]
- ** Description :
- ** When a timer interrupt occurs this event is called (only
- ** when the component is enabled - <Enable> and the events are
- ** enabled - <EnableEvent>). This event is enabled only if a
- ** <interrupt service/event> is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- void TI1_OnInterrupt(void)
- {
- /* Write your code here ... */
- if(!(ACELERADOR_GetVal()))
- {
- acionador=1;
- acc=acc+100;
- if(acc>5500)
- acc=5500;
- } else{
- acionador=0;
- }
- if((acc<5500&&acc>0||acc==5500)&&acionador==0)
- {
- acc=acc-100;
- }
- if(acc<0)
- acc=0;
- }
- /*
- ** ===================================================================
- ** Event : TI2_OnInterrupt (module Events)
- **
- ** Component : TI2 [TimerInt]
- ** Description :
- ** When a timer interrupt occurs this event is called (only
- ** when the component is enabled - <Enable> and the events are
- ** enabled - <EnableEvent>). This event is enabled only if a
- ** <interrupt service/event> is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- void TI2_OnInterrupt(void)
- {
- /* Write your code here ... */
- if(!(FREIO_GetVal()))
- {
- acionador2=1;
- fr=fr+100;
- if(fr>5500)
- fr=6000;
- } else{
- acionador2=0;
- }
- if((fr<6000&&fr>0||fr==6000)&&acionador2==0)
- {
- fr=fr-100;
- }
- if(fr<0)
- fr=0;
- }
- /* END Events */
- /*
- ** ###################################################################
- **
- ** This file was created by Processor Expert 3.02 [04.44]
- ** for the Freescale HCS12 series of microcontrollers.
- **
- ** ###################################################################
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement