Komisches Verhalten ATmega16 + Fleury LCD (ständig reset?)

Gast #1257172
Lesenswert?

Hi,

ich suche den ganzen Tag schon an einem Fehler bei meiner Schaltung oder 
im Programm. Ich habe an einem ATmega16 ein LCD an PORTA angeschlossen. 
Ich bekomme aber keine Ausgabe und anscheinend immer einen reset des 
AVR!
Resetpin ist mit 10k gegen Vcc=+5V angeschlossen. Beide GND-pins sind 
auf GND gelegt.

Folgend die Anschlussbelegung:

PA0 -- D4
PA1 -- D5
PA2 -- D6
PA3 -- D7
PA4 -- RS
PA5 -- R/W
PA6 -- E

Das Diplay liegt an 5V, Kontrast maximal (GND), D0-D3 auf GND.
ATmega16 ist mit einem 8MHz Quarz + 22pF Kondensatoren versehen.

An PC7 ist eine LED angeschlossen, sobald ich das Programm auf den 
Controller lade, fängt die LED an zu blinken! Auf dem Diplay erscheint 
nur ein Balken über die ganze Zeile.
Ich nehme mal an, dass das Blinken durch einen Reset zu erklären ist. 
das komische, sobald ich Vcc vom Display trenne, hört das Blinken auf, 
verbinde ich das Display wieder, blinkt die LED auch wieder. ???


Auszug aus der lcd.h von Fleury:
1
#define XTAL 8000000              /**< clock frequency in Hz, used to calculate delay timer */
2

3

4
/**
5
 * @name  Definition for LCD controller type
6
 * Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
7
 */
8
#define LCD_CONTROLLER_KS0073 0  /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
9

10
/** 
11
 *  @name  Definitions for Display Size 
12
 *  Change these definitions to adapt setting to your display
13
 */
14
#define LCD_LINES           2     /**< number of visible lines of the display */
15
#define LCD_DISP_LENGTH    16     /**< visibles characters per line of the display */
16
#define LCD_LINE_LENGTH  0x40     /**< internal line length of the display    */
17
#define LCD_START_LINE1  0x00     /**< DDRAM address of first char of line 1 */
18
#define LCD_START_LINE2  0x40     /**< DDRAM address of first char of line 2 */
19
#define LCD_START_LINE3  0x14     /**< DDRAM address of first char of line 3 */
20
#define LCD_START_LINE4  0x54     /**< DDRAM address of first char of line 4 */
21
#define LCD_WRAP_LINES      0     /**< 0: no wrap, 1: wrap at end of visibile line */
22

23

24
#define LCD_IO_MODE      1         /**< 0: memory mapped mode, 1: IO port mode */
25
#if LCD_IO_MODE
26
/**
27
 *  @name Definitions for 4-bit IO mode
28
 *  Change LCD_PORT if you want to use a different port for the LCD pins.
29
 *
30
 *  The four LCD data lines and the three control lines RS, RW, E can be on the 
31
 *  same port or on different ports. 
32
 *  Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
33
 *  different ports. 
34
 *
35
 *  Normally the four data lines should be mapped to bit 0..3 on one port, but it
36
 *  is possible to connect these data lines in different order or even on different
37
 *  ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
38
 *  
39
 */
40
#define LCD_PORT         PORTA        /**< port for the LCD lines   */
41
#define LCD_DATA0_PORT   LCD_PORT     /**< port for 4bit data bit 0 */
42
#define LCD_DATA1_PORT   LCD_PORT     /**< port for 4bit data bit 1 */
43
#define LCD_DATA2_PORT   LCD_PORT     /**< port for 4bit data bit 2 */
44
#define LCD_DATA3_PORT   LCD_PORT     /**< port for 4bit data bit 3 */
45
#define LCD_DATA0_PIN    0            /**< pin for 4bit data bit 0  */
46
#define LCD_DATA1_PIN    1            /**< pin for 4bit data bit 1  */
47
#define LCD_DATA2_PIN    2            /**< pin for 4bit data bit 2  */
48
#define LCD_DATA3_PIN    3            /**< pin for 4bit data bit 3  */
49
#define LCD_RS_PORT      LCD_PORT     /**< port for RS line         */
50
#define LCD_RS_PIN       4            /**< pin  for RS line         */
51
#define LCD_RW_PORT      LCD_PORT     /**< port for RW line         */
52
#define LCD_RW_PIN       5            /**< pin  for RW line         */
53
#define LCD_E_PORT       LCD_PORT     /**< port for Enable line     */
54
#define LCD_E_PIN        6            /**< pin  for Enable line     */

Die Main:
1
#include <avr/io.h> 
2
#include <stdlib.h>
3
#include "lcd.h"
4

5
int main(void)
6
{
7
  
8
  DDRC=0xFF;
9
  PORTC |= (1<<PC7);
10
  
11
  lcd_init(LCD_DISP_ON);
12
  lcd_clrscr();
13
  lcd_home();
14
  lcd_puts("Line 2");
15
   
16
  while(1);
17
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren