Forum: Mikrocontroller und Digitale Elektronik ASt7, WS2812 Fehlermeldung: "internal error: out of range error"


von Lumen (Gast)


Lesenswert?

Den Code habe ich abgekupfert: 
Beitrag "Re: Lightweight WS2811/WS2812 Library"

Beim Compilieren mit dem Atmel Studio 7 erhalte ich eine Fehlermeldung 
("internal error: out of range error"). Der Cursor steht auf der Zeile 
25 ("asm volatile").

Was ist außerhalb des Bereichs in der Assemblerkonstruktion?
1
#include <avr/io.h>
2
3
/*
4
5
  RGB 3 x 8 Bits 24 Bits 
6
  
7
  0er Bit = High (0,35 µs (+/- 150 n) Low  (0,9 µs +/- 150 n)
8
  1er Bit = Low  (0,35 µs (+/- 150 n) High (0,9 µs +/- 150 n)
9
  
10
  Reset   = Low (> 50 µs)
11
12
*/
13
14
#define ws2812_port 0x18  // Number of the data port register
15
#define ws2812_pin 4    // Number of the data out pin
16
17
void WS2812SendBytes(uint8_t *data, uint16_t n)
18
{
19
  uint8_t curbyte,ctr;
20
  
21
  while (n--)
22
  {
23
    curbyte=*data++;
24
    
25
    asm volatile
26
    (
27
    "    ldi  %0,8       \n\t"    // 0
28
    "    nop\n\t"
29
30
    "loop%=:lsl  %1      \n\t"    //  1     Datenbit ins Carry
31
    "    dec  %0         \n\t"    //  2     Schleifenzähler in Z-Flag
32
    "    sbi  %2,  %3    \n\t"    //  4
33
34
    "    nop\n\t"                  //  5
35
    "    nop\n\t"                  //  6
36
37
    "    brcs .+2        \n\t"    //  7l / 8h
38
    "    cbi  %2,  %3    \n\t"    //  9l / -    Überspringen bei C=1
39
40
    "    nop\n\t"                  // 10l /  9h
41
    "    nop\n\t"                  // 11l / 10h
42
    "    nop\n\t"                  // 12l / 11h
43
    "    nop\n\t"                  // 13l / 12h
44
    
45
    "    brcc .+3        \n\t"    // 15l / 13h
46
    "    cbi  %2,  %3    \n\t"    // -  / 15h   Überspringen bei C=0
47
48
    "    nop\n\t"                  // 16
49
    "    nop\n\t"                  // 17
50
    "    nop\n\t"                  // 18
51
    "    nop\n\t"                  // 19
52
53
    "    brne loop%=     \n\t"    // 11 loop /10nt  Weiter, wenn Z=1
54
55
    :  "=&d" (ctr)
56
    :  "r" (curbyte), "I" (ws2812_port), "I" (ws2812_pin)
57
    );
58
    
59
    // loop overhead including byte load is 6+1 cycles
60
  }
61
}
62
63
uint8_t LED[] = 
64
{
65
  0x30, 0x60, 0x90
66
};
67
68
int main(void)
69
{
70
  WS2812SendBytes(LED, 3);
71
  
72
    while (1) 
73
    {
74
    }
75
}

von Lumen (Gast)


Lesenswert?

Erledigt. In der Zeile

"    brcc .+2        \n\t"    // 15l / 13h

muss .+2 nicht .+3 stehen.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.