0 Members and 2 Guests are viewing this topic.
Imho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.More: http://playground.arduino.cc/Main/SID-emulator
Quote from: SpiroH on January 18, 2013, 10:25:17 amImho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.What do you mean by that?
Imho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.
#include <SID.h>// MACROs#define PIN2H (PIND & 0B00000100)#define PIN3L !(PIND & 0B00001000)#define CLR(x,y) (x&=(~(1<<y)))#define SET(x,y) (x|=(1<<y))SID mySid;void setup() { pinMode(2,INPUT); pinMode(3,INPUT); mySid.begin();}byte n=0;int timer=0;byte count=0;byte get=B00000000;int addrval[2] = {0};void loop(){ do{ do { if (PIN3L) // If the clock pin is LOW { if (PIN2H) // And the data pin is HIGH { CLR(get,count); // CLEAR BIT } else // otherwise { SET(get,count); // SET BIT } count++; // Increase the bit counter while(PIN3L) // Wait until the clock pin goes HIGH again { timer++; // Increase the timeout timer if (timer==500){// Timeout at 500 loops n=count=0; // Reset counters break; // Break free } } timer=0; // Reset the timeout timer } }while(count!=8); // Loop again when the bit counter has not reached 8 bits yet addrval[n]=get; // Otherwise store the received byte in an array in cell n n++; // Increase the byte counter count=0; // Reset the bit counter }while(n!=2); // Loop again when the byte counter has not reached two bytes yet // Otherwise write the value to the register. mySid.set_register(addrval[0], addrval[1]); n=0; // Reset the byte counter}
I tried to optimize the arduino code, but it's not getting an awful lot faster since my first optimization.....
I already use timer interrupts for the sid emulation library. Can I use these in parallel?
.. I watched the signal on the scope.