Hallo an die Experten:
ich habe ein proMicro board mit einem ATmega32U4 drauf.
Die HW scheint okay - ich kann damit alles machen, der uC läuft korrekt.
Nur gelingt es mir nicht die USB Schnittstelle zu initialisieren.
Ich benutze Standard-Code aus dem Netz, den ich auch verstehe.
1 | //-------------------------
|
2 | int16_t usb_init (void)
|
3 | //-------------------------
|
4 | {
|
5 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
|
6 | {
|
7 | UHWCON |= (1 << UVREGE); // Enable USB Pads Regulator
|
8 |
|
9 | // configure PLL interface
|
10 | PLLCSR = 0;
|
11 | PLLFRQ = 0;
|
12 |
|
13 | PLLFRQ = 0b00001010; // 96MHz
|
14 | PLLFRQ |= (1 << PLLUSB); // /2 = 48MHz USB clock
|
15 | PLLCSR |= (1 << PINDIV); // external 16MHz source
|
16 |
|
17 | // enable PLL
|
18 | PLLCSR |= (1 << PLLE);
|
19 |
|
20 | // check PLL lock
|
21 | while (!(PLLCSR & (1 << PLOCK)));
|
22 |
|
23 | USBCON |= (1 << USBE) | (1 << OTGPADE); // Enable USB Controller and USB power pads
|
24 | USBCON &= ~(1 << FRZCLK); // Unfreeze the clock
|
25 | UDCON &= ~(1 << LSM); // FULL SPEED MODE
|
26 | UDCON &= ~(1 << DETACH); // Attach USB Controller to the data bus
|
27 | UDINT = 0;
|
28 | UDIEN |= (1 << EORSTE) | (1 << SOFE); // Re-enable the EORSTE (End Of Reset) Interrupt so we know when we can configure the control endpoint usb_config_status = 0;
|
29 | }
|
30 | return 0;
|
31 | }
|
Dieser läuft alles korrekt durch, NUR: am Ende aktviere ich den EORSTE
Interrupt, d.h. diese ISR
1 | //--------------------
|
2 | ISR (USB_GEN_vect)
|
3 | //--------------------
|
4 | {
|
5 | uint8_t USB_InterruptSource;
|
6 |
|
7 | USB_InterruptSource = UDINT;
|
8 | UDINT = 0;
|
9 |
|
10 | DDRD |= 1;
|
11 | PORTD |= 1;
|
12 | _delay_ms (1);
|
13 | PORTD &= 254;
|
14 | return;
|
sollte sofort angesprungen und ausgeführt werden - WIRD SIE ABER NICHT.
wie zuletzt auch der Oszi am PORT D0 zeigt...
Was mache ich falsch? Irgendeine Dummheit? Irgendetwas übersehen/falsch
gelesen?
Vielleicht sieht ja jemand auf den ersten Blick etwas...
Danke
G.S.