Hola Nocturno,
Primero agradecer tu ayuda, por fin pude hacerlo.
Ahora estoy con el lab8 y no paso la prueba del simulador: Todo va bien hasta que llego al PAso 3 del Grader donde pone:
3) Switch not pressed test, LED should be on :
Fail: LED should be on when switch is not pressed
no entiendo pq no lo paso. Adjunto mi programa a ver si alguien me puede hechar una mano.
Por ultimo, cuando simulo en el Realboard me da 100 puntos. No se, no lo entiendo.
Saludos y muchas gracias
// ***** 0. Documentation Section *****
// SwitchLEDInterface.c for Lab 8
// Runs on LM4F120/TM4C123
// Use simple programming structures in C to toggle an LED
// while a button is pressed and turn the LED on when the
// button is released. This lab requires external hardware
// to be wired to the LaunchPad using the prototyping board.
// January 11, 2014
// Lab 8
// Jon Valvano and Ramesh Yerraballi
// November 21, 2013
// ***** 1. Pre-processor Directives Section *****
#include "TExaS.h"
#include "tm4c123gh6pm.h"
// ***** 2. Global Declarations Section *****
// FUNCTION PROTOTYPES: Each subroutine defined
void DisableInterrupts(void); // Disable interrupts
void EnableInterrupts(void); // Enable interrupts
void PortE_Init(void); //PortE initaliza
void delay(unsigned long halfsecs);
// ***** 3. Subroutines Section *****
// PE0, PB0, or PA2 connected to positive logic momentary switch using 10 k ohm pull down resistor
// PE1, PB1, or PA3 connected to positive logic LED through 470 ohm current limiting resistor
// To avoid damaging your hardware, ensure that your circuits match the schematic
// shown in Lab8_artist.sch (PCB Artist schematic file) or
// Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat).
//GLobal Variables
unsigned long in,out;
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
EnableInterrupts(); // enable interrupts for the grader
PortE_Init();
while(1){
in=(GPIO_PORTE_DATA_R & 0x01);
if (in== 0x00){
GPIO_PORTE_DATA_R=0x02;
}
else{
GPIO_PORTE_DATA_R^=0x02;
delay(1);
}
}
}
void PortE_Init(void){ unsigned long volatile delay;
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOE; // Port E clock
delay = SYSCTL_RCGC2_R; // wait 3-5 bus cycles
GPIO_PORTE_DIR_R |= 0x02; // PE1 output
GPIO_PORTE_DIR_R &= ~0x01; // PE0 input
GPIO_PORTE_AFSEL_R &= ~0x03; // not alternative
GPIO_PORTE_AMSEL_R &= ~0x03; // no analog
GPIO_PORTE_PCTL_R &= ~0x0000F00F; // bits for PD3, PD0
GPIO_PORTE_DEN_R |= 0x03; // enable PE1, PE0
}
// Subroutine to delay in units of half seconds
// We will make a precise estimate later:
// For now we assume it takes 1/2 sec to count down
// from 2,000,000 down to zero
// Inputs: Number of half seconds to delay
// Outputs: None
// Notes: ...
void delay(unsigned long halfsecs){
unsigned long count;
while(halfsecs > 0 ) { // repeat while there are still halfsecs to delay
count = 1538460; // 400000*0.5/0.13 that it takes 0.13 sec to count down to zero
while (count > 0) {
count--;
} // This while loop takes approximately 3 cycles
halfsecs--;
}
}