Update ES/Lab/LAB6/JOHNSON_Counter.c

This commit is contained in:
aadit 2025-09-11 12:01:22 +05:30
parent 6744ea11bc
commit 91765f4e0b

View file

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