MIT-Curricular/ES/Lab/LAB6/JOHNSON_Counter.c

30 lines
514 B
C

#include <LPC17xx.h>
int main(){
unsigned long x, i;
// from P1.24 -> 31
LPC_PINCON->PINSEL3 &= 0x0000FFFF; // values
LPC_GPIO1->FIODIR = 0xFF000000;
x = 0x01000000; // new variable
while(1){
x = 0x01000000;
// LOOP to fill 24->31 incrementally
for(i=0;i<8;i++){
LPC_GPIO1->FIOSET=x;
x = x<<1;
}
// for(i=0; i<1000; i++); // delay
// LOOP to empty 24->31 incrementally.
x = 0x01000000;
for(i=0;i<8;i++){
LPC_GPIO1->FIOCLR=x;
x = x<<1;
}
// for(i=0; i<1000; i++); //delay
}
}