int main(void){ /** * Initialisation of the ARM7 **/ GPIO_CONFIG(); //GPIO Konfiguration INIT_FREQ(); //Frequenz Einstellung init_lcd(); write_lcd('D',0); write_lcd('O',0); write_lcd('G',0); write_lcd('M',0); write_lcd(' ',0); write_lcd('I',0); write_lcd('N',0); write_lcd('I',0); write_lcd('T',0); while(1); return 0; } void INIT_FREQ(void) { PLLKEY1 = 0xAA; PLLCON = 0x21; //PLL Default configuration, internal 32 kHz oscillator PLLKEY2 = 0x55; POWKEY1 = 0x01; POWCON = 0x02; // CPU clock divider bits ==> 10,44MHz POWKEY2 = 0xF4; } //GPIO Konfiguration void GPIO_CONFIG(void) { /** **P1.0, P1.1, P1.2, P1.3 Configured as GPIO (00 bits) **/ GP1CON = 0x00000000; /** **bit 31 : RS <=> P1.7 Dir : output **bit 30 : E <=> P1.6 Dir : output **bit 29 : 4-Bits <=> P1.5 Dir : output **bit 28 : RW <=> P1.4 Dir : output **bit 27 : DB7 <=> P1.3 Dir : output **bit 26 : DB6 <=> P1.2 Dir : output **bit 25 : DB5 <=> P1.1 Dir : output **bit 24 : DB4 <=> P1.0 Dir : output **/ GP1DAT = 0xFF000000; GP1SET = 0x00000000; } void init_lcd(void) { lcd_clear_e(); lcd_clear_rw(); delay_lcd(500000); lcd_send_bits(0x03); lcd_clear_rs(); for( i_n = 3; i_n; i_n--){ lcd_pulse(); } lcd_send_bits(0x02); lcd_pulse(); write_lcd(0x29,1); // 4-Bit IS 0,1 write_lcd(0x53,1); // 52 Boster aus, Kontrast C5,C4 write_lcd(0x69,1); // 69 Spannungsfolger und Verstärkung write_lcd(0x74,1); // Kontrast C3,C2,C1 write_lcd(0x0F,1); // Display ein, Cursor ein, Cursor blinken write_lcd(0x06,1); // Autoincrement clear_lcd(); } void lcd_set_rs(void){ int LCD_RS = (0x1 << 23); GP1SET |= LCD_RS; } void lcd_set_e(void) { int LCD_E = (0x1 << 22); GP1SET |= LCD_E; } void lcd_clear_rs(void) { int LCD_RS = (0x1 << 23); GP1DAT &= ~LCD_RS; } void lcd_set_rw(void) { int LCD_RW = (0x1 << 20); GP1SET |= LCD_RW; } void lcd_clear_rw(void) { int LCD_RW = (0x1 << 20); GP1DAT &= ~LCD_RW; } void lcd_clear_e(void) { int LCD_E = (0x1 << 22); GP1DAT &= ~LCD_E; } void delay_lcd(unsigned long a){ while (--a!=0); } void clear_data(void){ int x = 0xF; x <<= 16; GP1DAT &= ~x; } void lcd_send_bits(int data){ data &= 0x0F; data <<= 16; clear_data(); GP1SET |= data; } void lcd_pulse(void){ lcd_set_e(); delay_lcd(20000); lcd_clear_e(); delay_lcd(20000); } void clear_lcd(void) { write_lcd(0x01,1); delay_us(200); } void write_lcd(byte lcd_byte, byte lcd_mode) { if (lcd_mode) //comand lcd_clear_rs(); else lcd_set_rs(); lcd_send_bits((lcd_byte & 0xF0) >> 4); lcd_pulse(); lcd_send_bits((lcd_byte & 0x0F)); lcd_pulse(); }