Moin zusammen und fröhliche Weihnachten,
gleich vorneweg, ich erwarte über die Feiertage keine Antwort -> es gibt schließlich Wichtigers in diesen Tagen!!! Ich will es nur schonmal "loswerden".
Also ich will mir einen kleinen USB-Switch bauen um zum Beispiel meinen Drucker an 2 PC's anzuschließen, und dann mittels Schalter den PC zu wechseln.
Da ich noch Anfänger im Bereich der Elektronik bin, stelle ich mir das wahrscheinlich viel zu einfach vor, und übersehe einige grundlegende Details.
Ich hoffe, dass mir jemand bezüglich meines angehängten Schaltplans und Controllercode, helfen kann dieses Projekt zu einem qualmfreien Ende zu führen.
Ich bin mir nicht so schlüssig, ob ich was das "Durchschleifen" der Signale betrifft, so richtig vorgegangen bin. Müssen D- und D+gekreuzt werden?
Gruß
Demian
Code:'General $regfile = "m8def.dat" 'ATMega8-Declaration $crystal = 3686400 'Quarz: 3,6864 Mhz 'Interrupts On Int0 Switchusb 'USB-Switch Routine Enable Int0 'activate INT0 interrupt Config Int0 = Rising 'when pushing button Enable Interrupts 'allow interrupts global 'Variables Dim USB As Bit '0=USB1, 1=USB2 'Input USB Config Portb.0 = Input 'VBUS Config Portd.5 = Input 'GND Config Portd.6 = Input 'D+ Config Portd.7 = Input 'D- 'Output USB 1 Config Portc.1 = Output 'LED Config Portc.2 = Output 'D- Config Portc.3 = Output 'VBUS Config Portc.4 = Output 'GND Config Portc.5 = Output 'D+ 'Output USB 2 Config Portb.1 = Output 'LED Config Portb.2 = Output 'D- Config Portb.3 = Output 'VBUS Config Portb.4 = Output 'GND Config Portb.5 = Output 'D+ 'Initialize USB = 0 'start with USB 1 Portd.2 = 1 'enable internal pullup for button 'Mainloop Main: Select Case USB Case 0 Portb.1 = 0 'USB 2 LED off Portc.1 = 1 'USB 1 LED on Portc.2 = Portd.7 'D- of USB Input to D- of USB Output Portc.3 = Portb.0 'VBUS from USB Input to VBUS of USB Output Portc.4 = Portd.5 'GND of USB Input to GND of USB Output Portc.5 = Portd.6 'D+ of USB Input to D+ of USB Output Case 1 Portc.1 = 0 'USB 1 LED off Portb.1 = 1 'USB 2 LED on Portb.2 = Portd.7 'D- of USB Input to D- of USB Output Portb.3 = Portb.0 'VBUS from USB Input to VBUS of USB Output Portb.4 = Portd.5 'GND of USB Input to GND of USB Output Portb.5 = Portd.6 'D+ of USB Input to D+ of USB Output End Select Goto Main Switchusb: Toggle USB Return







Zitieren
Lesezeichen