Hey Guys, I am new to µcontrollers I've just finished my new led cube 3x3x3. But I have a little problem with the program in c on my mac. I am using xcode for my play ground and avr-dude to program it with my usb asp on my mac. ok so my problem is that I looked for a good design but couldn't find one for the ATtiny 2313 so I designed my schematics etc on my own... and due to that reason that program I downloaded is not working. I found out that i used the same I/O pins like the guy my difference is that I used npn ( 3904 ) transistors for the layers... now I need to change the 3 I/O pins from sinking to sourcing... I'll include the main.c file for you guys to look over it I already have an idea and will include it as you'll see. That is my problem oh and that my aver-dude is new so its not accepting the old const prog_char... I get this error -------- begin -------- avr-gcc (GCC) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiling C: main.c avr-gcc -c -mmcu=attiny2313 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o main.c:1:3: error: expected identifier or '(' before '/' token **/ Mini-LED-Cube 1.0 ^ In file included from /usr/local/CrossPack-AVR-20131216/lib/gcc/avr/4.8.1/include/stdint.h:9:0 , from /usr/local/CrossPack-AVR-20131216/avr/include/inttypes.h:37, from /usr/local/CrossPack-AVR-20131216/avr/include/util/delay.h:42, from main.c:9: /usr/local/CrossPack-AVR-20131216/avr/include/stdint.h:159:1: error: unknown type name 'int8_t' typedef int8_t int_least8_t; ^ /usr/local/CrossPack-AVR-20131216/avr/include/stdint.h:213:1: error: unknown type name 'int8_t' typedef int8_t int_fast8_t; ^ main.c:31:1: warning: function declaration isn't a prototype [-Wstrict-prototypes] void init(); ^ main.c:63:1: error: unknown type name 'prog_char' const prog_char program_1[] = ^ main.c:107:38: error: 'FLASH' undeclared here (not in a function) unsigned int program_length = sizeof(FLASH STRING); ^ main.c:107:44: error: expected ')' before 'STRING' unsigned int program_length = sizeof(FLASH STRING); ^ In file included from main.c:12:0: main.c: In function 'main': main.c:119:53: error: 'program_pointer' undeclared (first use in this function) unsigned char instruction = pgm_read_byte(&(program_pointer[program_counter])); ^ main.c:119:53: note: each undeclared identifier is reported only once for each function it appears in main.c: At top level: main.c:220:6: warning: function declaration isn't a prototype [-Wstrict-prototypes] void init() ^ main.c:248:8: error: attempt to use poisoned "SIG_OUTPUT_COMPARE1A" SIGNAL(SIG_OUTPUT_COMPARE1A) ^ In file included from main.c:10:0: main.c: In function 'SIG_OUTPUT_COMPARE1A': main.c:248:8: warning: 'SIG_OUTPUT_COMPARE1A' appears to be a misspelled signal handler [enabled by default] SIGNAL(SIG_OUTPUT_COMPARE1A) ^ make: *** [main.o] Error 1 Nikans-MBP:attinyTest-2 Nikan$ clear Nikans-MBP:attinyTest-2 Nikan$ make -------- begin -------- avr-gcc (GCC) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiling C: main.c avr-gcc -c -mmcu=attiny2313 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o main.c:1:3: error: expected identifier or '(' before '/' token **/ Mini-LED-Cube 1.0 ^ In file included from /usr/local/CrossPack-AVR-20131216/lib/gcc/avr/4.8.1/include/stdint.h:9:0 , from /usr/local/CrossPack-AVR-20131216/avr/include/inttypes.h:37, from /usr/local/CrossPack-AVR-20131216/avr/include/util/delay.h:42, from main.c:9: /usr/local/CrossPack-AVR-20131216/avr/include/stdint.h:159:1: error: unknown type name 'int8_t' typedef int8_t int_least8_t; ^ /usr/local/CrossPack-AVR-20131216/avr/include/stdint.h:213:1: error: unknown type name 'int8_t' typedef int8_t int_fast8_t; ^ main.c:31:1: warning: function declaration isn't a prototype [-Wstrict-prototypes] void init(); ^ main.c:63:1: error: unknown type name 'prog_char' const prog_char program_1[] = ^ main.c:106:1: error: unknown type name 'prog_char' const prog_char *program_pointer = program_1; ^ main.c:220:6: warning: function declaration isn't a prototype [-Wstrict-prototypes] void init() ^ main.c:248:8: error: attempt to use poisoned "SIG_OUTPUT_COMPARE1A" SIGNAL(SIG_OUTPUT_COMPARE1A) ^ In file included from main.c:10:0: main.c: In function 'SIG_OUTPUT_COMPARE1A': main.c:248:8: warning: 'SIG_OUTPUT_COMPARE1A' appears to be a misspelled signal handler [enabled by default] SIGNAL(SIG_OUTPUT_COMPARE1A) ^ make: *** [main.o] Error 1 // Interner RC-Oszillator, CKDIV8 Disabled #define F_CPU 8000000UL // Includes #include <util/delay.h> #include <avr/interrupt.h> #include <avr/io.h> #include <avr/pgmspace.h> // Bitpopelei #define set_bit(var, bit) ((var) |= (1 << (bit))) #define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) // Bool #define FALSE 0 #define TRUE 1 // Definitionen #define PIXEL_TON 30 #define PIXEL_TOFF 10 // Cube-Array unsigned char cube[3][3][3]; unsigned char buffer[3][3][3]; // Framebuffer // Prototypen void init(); // Programmzähler unsigned int program_counter = 0; // Framezähler volatile unsigned char frame_counter = 0, fps = 0; // Pixelmakros #define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) #define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) // Instructions #define CLEAR 0b10000000 #define SET 0b10010000 #define FPS 0b10110000 #define NEXT 0b11110000 // Variablen #define VAR_FPS 0 // Für CLEAR und SET #define CLEAR_ALL 0 #define SET_ALL 0 // Für NEXT #define JUMP_FORWARD 1 #define JUMP_BACKWARD 2 // Programmcode const prog_char program_1[] = { FPS, 10, CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, // Vor- und zurück tanzen CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, CLEAR, SET + 12, NEXT, CLEAR, SET + 15, NEXT, CLEAR, SET + 12, NEXT, CLEAR, SET + 15, FPS, 5, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, // Umdrehung FPS, 5, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, FPS, 6, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, FPS, 6, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, FPS, 7, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, FPS, 7, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, FPS, 8, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, FPS, 8, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, FPS, 9, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, FPS, 9, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, FPS, 10, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, FPS, 10, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 12, NEXT, // Umfallen CLEAR, SET + 4, NEXT, CLEAR, SET + 5, NEXT, CLEAR, SET + 6, NEXT, // Ebenen CLEAR, SET + 1, NEXT, CLEAR, SET + 2, NEXT, CLEAR, SET + 3, NEXT, CLEAR, SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, FPS, 10, // Außen langlaufen CLEAR, PSET(0,0,0), PSET(1,0,0), PSET(0,1,0), PSET(1,1,0), PSET(0,2,0), PSET(1,2,0), NEXT, PCLEAR(0,0,0), PSET(2,0,0), PCLEAR(0,1,0), PSET(2,1,0), PCLEAR(0,2,0), PSET(2,2,0), NEXT, PCLEAR(1,0,0), PSET(2,0,1), PCLEAR(1,1,0), PSET(2,1,1), PCLEAR(1,2,0), PSET(2,2,1), NEXT, PCLEAR(2,0,0), PSET(2,0,2), PCLEAR(2,1,0), PSET(2,1,2), PCLEAR(2,2,0), PSET(2,2,2), NEXT, PCLEAR(2,0,1), PSET(1,0,2), PCLEAR(2,1,1), PSET(1,1,2), PCLEAR(2,2,1), PSET(1,2,2), NEXT, PCLEAR(2,0,2), PSET(0,0,2), PCLEAR(2,1,2), PSET(0,1,2), PCLEAR(2,2,2), PSET(0,2,2), NEXT, PCLEAR(1,0,2), PSET(0,0,1), PCLEAR(1,1,2), PSET(0,1,1), PCLEAR(1,2,2), PSET(0,2,1), NEXT, PCLEAR(0,0,2), PSET(0,0,0), PCLEAR(0,1,2), PSET(0,1,0), PCLEAR(0,2,2), PSET(0,2,0), NEXT, PCLEAR(0,0,1), PCLEAR(0,1,1), PCLEAR(0,2,1), SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 7, NEXT, }; const prog_char *program_pointer = program_1; unsigned int program_length = sizeof(program_1); // Main int main(void) { // Initialisierung init(); // Hauptschleife while (1) { unsigned char instruction = pgm_read_byte(&(program_pointer[program_counter])); if ((instruction & 0b10000000) == 0) // Pixel { unsigned char coord = instruction & 0b00111111; // Uns interessieren nur die 6 untersten Bits unsigned char y = coord / 9; unsigned char x = (coord - y * 9) % 3; unsigned char z = (coord - y * 9) / 3; buffer[x][y][z] = (instruction & 0b01000000) / 0b01000000; } else // Instruction { unsigned char operation = instruction & 0b11110000; // Uns interessieren nur die 4 obersten Bits if (operation == CLEAR || operation == SET) { unsigned char frame = instruction & 0b00001111; // Folgende Werte entsprechen SET_ALL unsigned char x_min = 0, x_max = 3, y_min = 0, y_max = 3, z_min = 0, z_max = 3; // Folgendes kann noch optimiert werden. // Y-Z-Ebene (links, mitte, rechts) if (frame == 1) { x_min = 0; x_max = 1; } if (frame == 2) { x_min = 1; x_max = 2; } if (frame == 3) { x_min = 2; x_max = 3; } // X-Z-Ebene (unten, mitte, oben) if (frame == 4) { y_min = 0; y_max = 1; } if (frame == 5) { y_min = 1; y_max = 2; } if (frame == 6) { y_min = 2; y_max = 3; } // X-Y-Ebene (hinten, mitte, vorne) if (frame == 7) { z_min = 0; z_max = 1; } if (frame == 8) { z_min = 1; z_max = 2; } if (frame == 9) { z_min = 2; z_max = 3; } if (frame < 10) { for (unsigned char z = z_min; z < z_max; z++) for (unsigned char y = y_min; y < y_max; y++) for (unsigned char x = x_min; x < x_max; x++) if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; } else { for (unsigned char a = 0; a < 3; a++) for (unsigned char b = 0; b < 3; b++) { unsigned char x = 0, y = 0, z = 0; if (frame == 10) { x = a; y = b; z = b; } // Unten hinten nach oben vorne if (frame == 11) { x = a; y = a; z = b; } // Unten links nach oben rechts if (frame == 12) { x = a; y = b; z = 2 - b; } // Unten vorne nach oben hinten if (frame == 13) { x = a; y = 2 - a; z = b; } // Oben links nach unten rechts if (frame == 14) { x = b; y = a; z = b; } // Hinten links nach vorne rechts if (frame == 15) { x = a; y = 2 - b; z = 2 - a; } // Vorne links nach hinten rechts if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; } } } else if (operation == FPS) { if (program_counter + 1 < program_length) program_counter++; // else: Fehler unsigned char byte = pgm_read_byte(&(program_pointer[program_counter])); fps = byte; } else if (operation == NEXT) { // VAR_FPS = 0: Frame nicht zeichnen, keine Wartezeit if (fps > 0) { // Temporäres Array ins "echte" Array kopieren for (unsigned char z = 0; z < 3; z++) for (unsigned char y = 0; y < 3; y++) for (unsigned char x = 0; x < 3; x++) cube[x][y][z] = buffer[x][y][z]; for (unsigned char i = 0; i < fps; i++) { _delay_ms(5); } } } } // Programmzähler erhöhen, bzw. bei Erreichen des Programmendes wieder von vorn beginnen if (program_counter + 1 < program_length) program_counter++; else program_counter = 0; } } // Initialisierung void init() { // Ports vorbereiten DDRB = 0b11111111; // PB0-PB7 = GND My idea is to change PORTB all to 0's to source PORTB = 0b11111111; // DDRD = 0b1111000; // PD6 = GND PD5-3 = +5v and here PD6 = 0 to source PORTD = 0b1000000; // Timer-Interrupt "TIMER1" vorbereiten cli(); set_bit(TIMSK, OCIE1A); set_bit(TCCR1B, WGM12); // Animations-Geschwindigkeit OCR1AH = 0x01; OCR1AL = 0x00; clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); sei(); } // Interruptvektor von TIMER1 SIGNAL(SIG_OUTPUT_COMPARE1A) { // Pixel multiplexen for (unsigned char z = 0; z < 3; z++) { for (unsigned char y = 0; y < 3; y++) { for (unsigned char x = 0; x < 3; x++) { unsigned char n = z * 3 + x; // LED an if (cube[x][y][z] == 1) { if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); set_bit(PORTD, y + 3); } // ON-Time for (unsigned long i = 0; i < PIXEL_TON; i++) { asm volatile("nop"::); } // LED aus if (cube[x][y][z] == 1) { clear_bit(PORTD, y + 3); if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); } // OFF-Time for (unsigned long i = 0; i < PIXEL_TOFF; i++) { asm volatile("nop"::); } } } } }
Well. start with the first error message, which is this one
1 | Compiling C: main.c |
2 | avr-gcc -c -mmcu=attiny2313 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o |
3 | |
4 | main.c:1:3: error: expected identifier or '(' before '/' token |
5 | **/ Mini-LED-Cube 1.0 |
The compiler even shows you the line in error
1 | **/ Mini-LED-Cube 1.0 |
There seems to be something wrong with the comment. Unfortunately I cannot see this line in the source code you posted. So make sure you compile the correct code. Correct that comment in your source code file and compile again. You will find that lots of errors have gone away. They are just errors, which are triggered by this erronous comment. > and due to that reason that program I downloaded is not working. It is not compiling because there are syntax errors. If your programm works or works not, nobody can say right now, because it does not even compile. > That is my problem Your problem is, that you think programming is something one does not need to learn BEFORE starting a project like a LED-cube. Start where everybody else starts: with a single LED on some port pin. Work your way upwards, including timer handling and in 3 or 4 month you have the knowledge to programm a LED cube. A cube is not a good project to start learning, for you need to know and have to have a lot of skills in programming such a beast. For a beginner it is much to compilcated.
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.