Hi,
me again. I've cleaned up the attiny85 midi code at
bitbucket, added pwm out and a 2nd analog input.
Possible tested I/O functions are:
PB0: Digital input or digital output or pwm output.
PB1: Digital input or digital output or pwm output (active high LED attached).
PB2: Digital input or digital output or analog input ADC1.
PB3, 4: USB data lines.
PB5: 1 analog input (ADC0, shared with the /Reset function, but you can apply a voltage between Vcc/2 and Vcc -> 512..1023 without resetting the device).
Ciao, Martin
EDIT 20170403:
I did some timing tests with an empty main loop, PB1 toggles every 3µs (idle) with a gap of 150µs (USB transfer) every 2ms.
So we still have >90% CPU time for our program available. This looks similar to
my measurements from 2009.
Test system: Lenovo T400 with Linux 4.10.8-towo.1-siduction-amd64 #1 SMP PREEMPT siduction 4.10-14 (2017-03-31) x86_64 GNU/Linux.
Short test on Win7 -> USB transfer every 8ms.
Win / Mac users: please double check on your systems.
Code: Select all
int main(void) // test loop
{
uchar iii, value;
uchar midiMsg[8];
DDRB |= 2; // LED pin output
PORTB |= 2; // LED on
setName( 0 );
usbDeviceDisconnect();
for(iii=0;iii<20;iii++){ /* 300 ms disconnect */
_delay_ms(15);
}
usbDeviceConnect();
PORTB &= ~2; // LED off
wdt_enable(WDTO_1S);
usbInit();
sei();
value = 0;
for(;;){ /* main event loop */
PORTB ^= 2; // toggle LED while idling
wdt_reset();
usbPoll();
if ( usbInterruptIsReady() ) { // prepare and start USB transfer
iii = 0;
midiMsg[iii++] = 0x0B;
midiMsg[iii++] = 0xB0;
midiMsg[iii++] = 70; // cc 70
midiMsg[iii++] = value++;
midiMsg[iii++] = 0x0B;
midiMsg[iii++] = 0xB0;
midiMsg[iii++] = 71; // cc 71
midiMsg[iii++] = value++;
usbSetInterrupt(midiMsg, iii); // transfer message
if ( value > 127 ) {
value = 0;
}
}
}
return 0;
}