//------------------------------------------------------------------------- // Titel : //------------------------------------------------------------------------- // Funktion : // Schaltung : //------------------------------------------------------------------------- // Prozessor : ATmega168 // Takt : 16000000 Hz // Sprache : C // Datum : 5.6.2010 // Version : 1.0 // Autor : // Programmer: // Port : //------------------------------------------------------------------------- // created by myAVR-CodeWizard //------------------------------------------------------------------------- // #define F_CPU 16000000 #include char eeRead(int adresse); #define BAUD 57600 void text0(); void text1(); void text2(); void text3(); void text4(); void text5(); void text6(); void text7(); void text8(); //---------------------------------------------------------------------- // Titel : C-Funktion Zeichen zu UART senden. //---------------------------------------------------------------------- // Funktion : ... // IN : char data // OUT : ... //---------------------------------------------------------------------- void uartPutChar(char data) { //warte bis UDR leer ist UCSRA / USR bei z.B.: 2313 while (!(UCSR0A&32)); //sende UDR0=data; } //---------------------------------------------------------------------- // Titel : C-Funktion Zeichenkette zu UART senden. //---------------------------------------------------------------------- // Funktion : ... // IN : char *buffer, Zeichenkette mit NUll abgeschlossen // OUT : ... //---------------------------------------------------------------------- void uartPutString(char *buffer) { for (int i=0; buffer[i] !=0;i++) uartPutChar (buffer[i]); } //-------------------------------------------------------------------- // Warte-Routine für 100 ms // die Routine wartet inclusive Aufruf 98,43 ms //-------------------------------------------------------------------- void myWait_100ms() { __asm__ volatile ( "push r16\n" "ldi r16,8\n" "myWait_100ms_3%=:\n" "push r16\n" "ldi r16,255\n" "myWait_100ms_2%=:\n" "push r16\n" "ldi r16,255\n" "myWait_100ms_1%=:\n" "dec r16 \n" "brne myWait_100ms_1%=\n" "pop r16 ; Register wiederherstellen\n" "dec r16 \n" "brne myWait_100ms_2%=\n" "pop r16 ; Register wiederherstellen\n" "dec r16 \n" "brne myWait_100ms_3%=\n" "pop r16 ; Register wiederherstellen\n" : : ); } //------------------------------------------------------------------------ // Initialisierungen //------------------------------------------------------------------------ void init() { // UART initialisieren UCSR0B |= _BV(3); // TX aktiv UCSR0B |= _BV(4); // RX aktivieren UBRR0=((F_CPU/BAUD)/16)-1; // Baudrate festlegen } ///////////////////////////////////////////////////////////////////////////// // Main-Funktion ///////////////////////////////////////////////////////////////////////////// main() { init(); // Initialisierungen while (true) // Mainloop-Begin { myWait_100ms() ; myWait_100ms() ; DDRD = 0x00; // PORTD = Eingang PORTD = 0x04; // PORTD = PULL-UP init(); text0(); do { if (!(PIND&0x04)) { text1(); break; } } while (true); do { if (!(PIND&0x04)) { text2(); break; } } while (true); do { if (!(PIND&0x04)) { text3(); break; } } while (true); do { if (!(PIND&0x04)) { text3(); break; } } while (true); //... } // Mainloop-Ende } //--------------------------------------------------------------------------- //-------------- void text0() { uartPutChar (0x0c); uartPutChar (0x09); uartPutChar (0x30); uartPutChar (0x0c); uartPutString (" THIS IS "); uartPutString (" A "); uartPutString (" PROJEKT "); uartPutString (" FROM "); uartPutString ("**********"); } //______________________________________________________________________________ void text1() { myWait_100ms() ; myWait_100ms() ; uartPutChar (0x0c); uartPutString ("MAXIMILIAN"); uartPutString (" KOERVERS "); uartPutString (" F12T1 "); uartPutString (" IN "); uartPutString (" ENGLISH "); } //___________________________________________________________________________ void text2() { myWait_100ms() ; myWait_100ms() ; uartPutChar (0x0c); uartPutString (" "); uartPutString (" HELLO "); uartPutString (" I AM THE "); uartPutString (" MAXX PDF "); } //___________________________________________________________________________ void text3() { myWait_100ms() ; myWait_100ms() ; uartPutChar (0x0c); uartPutChar (0x09); uartPutChar (0x0c); uartPutChar (0x0c); uartPutChar (0x0a); // 2 ZEILE uartPutString ("Hello, "); //3 uartPutString (" "); uartPutString ("Here is the newest model of the "); //6 uartPutString (" MAXX PDF . "); //7 uartPutString ("I'am a original produced product from a "); //8 uartPutString (" small German company in Dueren. "); //9 uartPutString ("Last month on an exhibition some Chinese"); //10 uartPutString ("Chinese takes photographs from me. "); //11 uartPutString ("Now you can buy the MAXPDF in China too."); //12 uartPutString ("So it seems to be easy to find out all "); //13 uartPutString ("about new products as Technical details,"); //14 uartPutString ("functions etc. for the product pirates "); //15 uartPutString ("to fake me. "); //16 uartPutString ("When I found reports in the media I was "); //17 uartPutString ("very curious to get more information "); //18 uartPutString ("about the enormous damage these "); //19 uartPutString ("piracy products cause. "); //20 } //______________________________________________________________________________ void text4() { myWait_100ms() ; uartPutString (" "); //1 uartPutString (" Here is my report: "); //2 uartPutString (" "); //3 uartPutString ("What does it mean "); //4 uartPutString (" “product and trademark piracy”? "); //5 uartPutString ("The product or pirates counterfeiters "); //6 uartPutString ("imitate or copy goods for which the "); //7 uartPutString ("legal producer holds rights. "); //8 uartPutString ("In addition the legal producer has "); //9 uartPutString (" invested a lot of work sometimes "); //10 uartPutString ("for years,and huge sums into "); //11 uartPutString ("the development. "); //12 uartPutString ("So it seems to be easy to find out all "); //13 uartPutString ("So the pirates use illegally the knowhow"); //14 uartPutString (", functions etc. for the product pirates"); //15 uartPutString ("and the reputation of the companies. "); //16 uartPutString ("By imitating products consumers are "); //17 uartPutString (" fooled about the true origin "); //18 uartPutString ("and the quality of the products. "); //19 uartPutString (" "); //20 } //___________________________________________________________________________ void text5() { } //___________________________________________________________________________ void text6() { } //______________________________________________________________________________ void text7() { } //___________________________________________________________________________ void text8() { }