LCD resets continuously

Thread Starter

Sergiu Coman

Joined Sep 16, 2016
2
Hello!

I am trying to make an automated watering system, just for passing the time and experiencing with the possibilities. I got an LCD for it, to make it possible for different options to be selected, etc.

The issue is that, after writing the driver for the LCD and trying to test it, i noticed that the RESET flag is always on when doing a status read, so no instructions are accepted.

I am using an XMC1100 Boot Kit for controlling the LCD, which is a RayStar RG12864B-BIW-V. The code is written in C, using the software provided by the manufacturer of the microcontroller.

Here is my code:

Header:

Code:
/*
* LCD_driver.h
*
*  Created on: Sep 6, 2016
*      Author: Sergiu
*/

#ifndef LCD_DRIVER_H_
#define LCD_DRIVER_H_

#define LCD_DATA 1
#define LCD_COMM 0
#define LCD_READ 1
#define LCD_WRITE 0
#define ON 1
#define OFF 0

void LCD_Init();
void LCD_Toggle();
void LCD_SetY(uint8_t address);
void LCD_SetPage(uint8_t page);
void LCD_SetStartLine(uint8_t line);
void LCD_Write(uint8_t code);
void LCD_Instruction(int DATA, int READ, uint8_t code);
uint8_t LCD_Read();
uint8_t StatusRead();
void LCD_Enable();

#endif /* LCD_DRIVER_H_ */

C source (I only added the needed functions):

Code:
#include <DAVE.h>
#include "LCD_driver.h"

void LCD_Init()
{
    int reset=1;
    while(reset)
    {
        reset=(StatusRead()>>4)&1;            //Checking if the LCD is still initializing
        if (reset)
        {
            for (int i=0;i<0xff;++i);
        }
    }
}

uint8_t StatusRead()
{
    uint8_t code;
    DIGITAL_IO_SetOutputLow(&D_I);                                    //Setting the pins to the correct output levels
    DIGITAL_IO_SetOutputHigh(&R_W);
    BUS_IO_SetMode(&DATA_BUS, XMC_GPIO_MODE_INPUT_TRISTATE);        //Setting the DATA BUS to input mode
    do
    {
        DIGITAL_IO_SetOutputHigh(&ENABLE);                            //E pin ->High
        for(int i=0;i<0xFF;++i);
        code=BUS_IO_Read(&DATA_BUS);                                //Reading the DATA BUS
        DIGITAL_IO_SetOutputLow(&ENABLE);
        for(int i=0;i<0xFF;++i);
    }while(code>=0x80);
    BUS_IO_SetMode(&DATA_BUS, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);        //Setting the DATA BUS to output mode
    return code;
}
 

Thread Starter

Sergiu Coman

Joined Sep 16, 2016
2
I did a Status read, as described in the datasheet linked in the post, in the function StatusRead(). The information received on the DATA_BUS is always 0x30, so the fourth MSB is 1, which means the system is being initialized and can't receive any other instructions except the status read. Also, the display is turned off, according to the reading, but that doesn't matter right now.

NOTE: I checked the connections multiple times and there is nothing wrong with them.
 
Top