My goal is to use the usb cable as a serial communication channel on my attiny88 mcus after the sketches been uploaded by micronucleus.
Does this goal make sense?
Will it interfere with the workings of micronucleus mechanism to upload sketches?
If it is possible, how should I go about to achieve my goals?
What you want to do "makes sense", but I don't know whether it's possible with V-USB (the bit-banging USB firmware that micronucleus uses.)
Emulating a serial port over USB normally uses a full-speed (12Mbps) connection and three USB "endpoints", while I think VUSB only does ONE low-speed endpoint.
Thanks for chiming in west.
I'm taking it a step at a time. I won't be getting anywhere near serialization before getting this thing to run, and now i'm stuck at the following code:
void setup() {
/* USB timing has to be exact, therefore deactivate Timer0 interrupt */
//TIMSK0 = 0;
TCCR0A = (1 << CTC0);
/* set the internal LED pin (normally D13) as output */
pinMode(LED_BUILTIN, OUTPUT);
}
int counter = 100;
int ledstatus = LOW;
int writer = 5;
void loop() {
/* call this function at least every 20ms, otherwise an USB timeout will occur */
mKeyboard.update();
/* check if button is pressed */
counter--;
if (counter<0){
if (ledstatus==HIGH){
ledstatus=LOW;
} else {
ledstatus=HIGH;
}
digitalWrite(LED_BUILTIN, ledstatus);
counter=100;
if (--writer<0) {
mKeyboard.printsln("Hello World!"); // <-- stuck over here..
writer = 5;
}
}
delayMicroseconds(10000);
}
Is it because i need to setup a hid application to listen to the keystrokes?
i'm currently trying to install SuperCollider.app and setting permissions hoping for something to happen..?
If you implement a keyboard, which should be possible with VUSB, the Tiny88 should end up appearing to your PC like an additional keyboard without any PC-side action on your part.
It's theoretically possible to establish "arbitrary" communications with the low-speed HID connection that VUSB does support. That's what the cheap "USBASP" device programmers do, and what micronucleus does for upload. But you would need special SW on the PC side.
Also, if you have a recent PC, it's possible that it is no longer willing to talk to VUSB devices. Apparently they only "almost" meet the USB low-speed specs, and some of the newer desktop USB controllers are pickier (in their need to support USB3/USBC and stuff.) Adafruit has had a warning on some of their VUSB products for a while now. (although, if you can "upload" via micronucleus, that should mean that things are working to that extent.)
The Trinket has a USB port that is used for bootloading. But the Trinket can only become a low-speed USB device because of its limited hardware. USB standards prevents low speed USB devices to truly act as virtual serial ports, which is why we cannot use a serial terminal to communicate with the Trinket directly.