Lab 8, Shape the World "SwitchLEDInterface"

En este Lab se hizo un ejemplo de una alarma, en mi caso recicle codigo que habia usado en los labs anteriores. El jueves pasado (Febrero 19) subieron una noticia, diciendo que este Lab8 y el Lab10 no activarian el scope y daban algunos pasos para poder agregarlo en dichos Labs, esto me dio problemas ya que las funciones del Timer4 no estaban implementadas dentro de una funcion que debiamos de invocar (TExaS_Scope();), asi que no la agregue, al final no influyo en el grader.

Los pasos que tenia que seguir el sistema son:

• Hacer PE1 salida y PE0 entrada.
• Iniciar con el LED encendido (PE1 = 1).
• Esperar 100 ms • Al presionar un switch (en mi caso lo llame boton, ubicado en PE0) toggleara el LED ubicado en PE1 cada 100ms.
• Repetir los pasos 3 y 4 una y otra vez.

Este es parte del codigo (las declaraciones de las funciones estan afuera del main), no era muy dificil, pero por no poder estudiar entre semana se me olvidaron algunas cosas XD.
    
 int main(void){ 
//**********************************************************************
// The following version tests input on PE0 and output on PE1
//**********************************************************************
  TExaS_Init(SW_PIN_PE0, LED_PIN_PE1);  // activate grader and set system clock to 80 MHz
  //TExaS_Scope();
 
  EnableInterrupts();           // enable interrupts for the grader
 
 PortE_Init();
 GPIO_PORTE_DATA_R |=0x02;    // LED On (PE1 = 1)
 Delay100ms(1);         // Wait 100 mS
 
  while(1){
    unsigned long boton = GPIO_PORTE_DATA_R&0x01;
   
 if(boton){
  GPIO_PORTE_DATA_R ^=0x02;
  Delay100ms(1);
  }else{
   GPIO_PORTE_DATA_R |=0x02;    // LED On (PE1 = 1)
  }
  }
  
}

// Subroutine to initialize port E pins for input and output
// PE0 is input SW1 and PE1 is output LEDs
// Inputs: None
// Outputs: None
// Notes: ...
void PortE_Init(void){ volatile unsigned long delay;
  SYSCTL_RCGC2_R |= 0x00000010;      // 1) E clock
  delay = SYSCTL_RCGC2_R;            // delay to allow clock to stabilize     
  GPIO_PORTE_AMSEL_R &= 0x00;        // 2) disable analog function
  GPIO_PORTE_PCTL_R &= 0x00000000;   // 3) GPIO clear bit PCTL  
  GPIO_PORTE_DIR_R &= 0x01;         // 4.1) PE0 input,
  GPIO_PORTE_DIR_R |= 0x02;          // 4.2) PE1 output  
  GPIO_PORTE_AFSEL_R &= 0x00;        // 5) no alternate function
  GPIO_PORTE_DEN_R |= 0x03;          // 7) enable digital pins PE1-PE0
}


void Delay100ms(unsigned long time){
 unsigned long i;
 while(time > 0){
  i=1333333;
   while(i > 0){
    i = i - 1;
   }
  time = time - 1;
 }
}

No tengo la board para checar si corre bien en hardware, al menos en software corrio bien.

Comentarios

Entradas más populares de este blog

PSoC Creator Tools

PSoC5LP Usando el SAR ADC y la señal EoS para manejar una LUT