int tics; int salida; int act; int buffer[8]; void main() { for (act = 0; act ++; act < 8) { buffer[act] = 0 ; } act = 0; tics = 0; enable(); while(TRUE) {}; } void interrupt timer() { //Si PULSO está en 1 aumento tics if( out(PULSO) & 0x01 == 0x01) then { if (tics < 50) then tics = tics + 1; } } //end timer() void interrupt flanco() { if (tics == 50) then { buffer[act] = 1; act = (act + 1) % 8; } if (tics == 30) then { buffer[act] = 0; act = (act + 1) % 8; } if (tics < 30) then { // proceso buffer salida = 0; j = (act - 1) % 8; for ( i = 1, i = i*2 , i <= 128) do { salida = salida + i* buffer[j]; j = (j - 1) % 8; } // escribo salida en SALIDA OUT(SALIDA, salida); // Limpio el buffer for (act=0 , act ++, act < 8) {buffer[act]= 0} act = 0; } //end if(tics<30) tics = 0; } //end flanco()