LCD resets continuously

Discussion in 'Embedded Systems and Microcontrollers' started by Sergiu Coman, Sep 16, 2016.

  1. Sergiu Coman

    Thread Starter New Member

    Sep 16, 2016
    2
    0
    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 (Text):
    1. /*
    2. * LCD_driver.h
    3. *
    4. *  Created on: Sep 6, 2016
    5. *      Author: Sergiu
    6. */
    7.  
    8. #ifndef LCD_DRIVER_H_
    9. #define LCD_DRIVER_H_
    10.  
    11. #define LCD_DATA 1
    12. #define LCD_COMM 0
    13. #define LCD_READ 1
    14. #define LCD_WRITE 0
    15. #define ON 1
    16. #define OFF 0
    17.  
    18. void LCD_Init();
    19. void LCD_Toggle();
    20. void LCD_SetY(uint8_t address);
    21. void LCD_SetPage(uint8_t page);
    22. void LCD_SetStartLine(uint8_t line);
    23. void LCD_Write(uint8_t code);
    24. void LCD_Instruction(int DATA, int READ, uint8_t code);
    25. uint8_t LCD_Read();
    26. uint8_t StatusRead();
    27. void LCD_Enable();
    28.  
    29. #endif /* LCD_DRIVER_H_ */
    30.  

    C source (I only added the needed functions):

    Code (Text):
    1. #include <DAVE.h>
    2. #include "LCD_driver.h"
    3.  
    4. void LCD_Init()
    5. {
    6.     int reset=1;
    7.     while(reset)
    8.     {
    9.         reset=(StatusRead()>>4)&1;            //Checking if the LCD is still initializing
    10.         if (reset)
    11.         {
    12.             for (int i=0;i<0xff;++i);
    13.         }
    14.     }
    15. }
    16.  
    17. uint8_t StatusRead()
    18. {
    19.     uint8_t code;
    20.     DIGITAL_IO_SetOutputLow(&D_I);                                    //Setting the pins to the correct output levels
    21.     DIGITAL_IO_SetOutputHigh(&R_W);
    22.     BUS_IO_SetMode(&DATA_BUS, XMC_GPIO_MODE_INPUT_TRISTATE);        //Setting the DATA BUS to input mode
    23.     do
    24.     {
    25.         DIGITAL_IO_SetOutputHigh(&ENABLE);                            //E pin ->High
    26.         for(int i=0;i<0xFF;++i);
    27.         code=BUS_IO_Read(&DATA_BUS);                                //Reading the DATA BUS
    28.         DIGITAL_IO_SetOutputLow(&ENABLE);
    29.         for(int i=0;i<0xFF;++i);
    30.     }while(code>=0x80);
    31.     BUS_IO_SetMode(&DATA_BUS, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);        //Setting the DATA BUS to output mode
    32.     return code;
    33. }
    34.  
     
  2. dannyf

    Well-Known Member

    Sep 13, 2015
    1,834
    367
    the obvious question is how do you know that?

    you didn't provide the lcd routines so the first order of business would be to make sure that they work.
     
  3. Sergiu Coman

    Thread Starter New Member

    Sep 16, 2016
    2
    0
    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.
     
Loading...