#define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
#define GPIO_PORTD_DATA_R (*((volatile unsigned long *)0x400073FC))
#define GPIO_PORTD_DIR_R (*((volatile unsigned long *)0x40007400))
#define GPIO_PORTD_AFSEL_R (*((volatile unsigned long *)0x40007420))
#define GPIO_PORTD_DEN_R (*((volatile unsigned long *)0x4000751C))
#define GPIO_PORTD_AMSEL_R (*((volatile unsigned long *)0x40007528))
#define GPIO_PORTD_PCTL_R (*((volatile unsigned long *)0x4000752C))
// Port B
#define GPIO_PORTB_DATA_R (*((volatile unsigned long *)0x400053FC))
#define GPIO_PORTB_DIR_R (*((volatile unsigned long *)0x40005400))
#define GPIO_PORTB_AFSEL_R (*((volatile unsigned long *)0x40005420))
#define GPIO_PORTB_DEN_R (*((volatile unsigned long *)0x4000551C))
#define GPIO_PORTB_CR_R (*((volatile unsigned long *)0x40005524))
#define GPIO_PORTB_AMSEL_R (*((volatile unsigned long *)0x40005528))
#define GPIO_PORTB_PCTL_R (*((volatile unsigned long *)0x4000552C))
unsigned long in,out, out2;
void ssd(int n);
void wait(void);
const char output[5] = {0x9B, // 4
0xB0, // 3
0xA4, // 2
0xF9, // 1
0xC0, // 0
};
int main(void){
unsigned long volatile delay;
unsigned long volatile delay1;
// Port D Initialization:
SYSCTL_RCGC2_R |= 0x08; // Port D clock
delay = SYSCTL_RCGC2_R; // wait 3-5 bus cycles
GPIO_PORTD_DIR_R |= 0x0A; // PD3, PD2 output
GPIO_PORTD_DIR_R &= ~0x01; // PD0 input
GPIO_PORTD_AFSEL_R &= ~0x09; // not alternative
GPIO_PORTD_AMSEL_R &= ~0x09; // no analog
GPIO_PORTD_PCTL_R &= ~0x0000F0FF; // bits for PD3, PD1, PD0
GPIO_PORTD_DEN_R |= 0x0B; // enable PD3, PD1, PD0
SYSCTL_RCGC2_R |= 0x02; // Port B clock
delay1 = SYSCTL_RCGC2_R; // wait 3-5 bus cycles
GPIO_PORTB_DIR_R |= 0xFF; // PB8-0 as output
GPIO_PORTB_AFSEL_R &= ~0xFF; // not alternative
GPIO_PORTB_AMSEL_R &= ~0xFF; // no analog
GPIO_PORTB_PCTL_R &= ~0xFFFFFFFF; // bits for PB8-0
GPIO_PORTB_DEN_R |= 0xFF; // enable PB8-0
int x = 2;
// Open loop:
while(x !=0 ){
in = (GPIO_PORTD_DATA_R&0x01); // in 0 if not pressed, 1 if pressed
if(in == 0x01){
out2 = (in^0x00)<<1;
out = (in^0x01)<<3;
// GPIO_PORTD_DATA_R = out;
//GPIO_PORTD_DATA_R = out2;
ssd(3);
}else if(in == 0x00){
out2 = (in^0x00)<<1;
out = (in^0x01)<<3;
// GPIO_PORTD_DATA_R = out2;
//GPIO_PORTD_DATA_R = out;
ssd(0);
}
}
} // End of design
// Method for delay:
void ssd(int n){
GPIO_PORTB_DATA_R = output[n];
}
I can't make it loop back when i wire up the circuit. It changes once and stop and does not loop back
It would be great if anyone would help me out.