Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] In LCD First line is displaying but not in the second line?

Status
Not open for further replies.

jack1998

Junior Member level 2
Joined
Oct 17, 2021
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
136
I am using an 8085 microcontroller and 16*2 LCD with a 4-bit data bus panel to display the RTC(the time and date ). Since now the Interface is working with displaying the time or date in the first line but it is not displaying on the second line. What may be the cause? Thank you!
To display the time I have used code as:

Code:
#define LCM_CONFIG_MAX_CHAR_PER_LINE                    (16)
#define _0x80_LCM_COMMAND_SET_DDRAM_ADDRESS                        (0x80U)

typedef enum {
LCM_POSITION_TOP = 0x00U, /* The left at the top line */
LCM_POSITION_BOTTOM = 0x40U, /* The left at the bottom line */
} lcm_position_t;

void r_rtc_display_current_time(void)
{
uint8_t string_time[13+1]; /* A string area for the time to display. */
st_rtc_counter_value_t read_val; /* Counter values read from RTC registers */

while(R_Config_RTC_Get_CounterValue(&read_val) != MD_OK)
{
;
}
/* Show "YY/MM/DD(DOW)" on the top of LCD. */
convert_BCD_to_2chars(read_val.year, &string_time[0]);
string_time[2] = '/';
convert_BCD_to_2chars(read_val.month, &string_time[3]);
string_time[5] = '/';
convert_BCD_to_2chars(read_val.day, &string_time[6]);
string_time[8] = '(';
convert_week_to_3chars(read_val.week, &string_time[9]);
string_time[12] = ')';
string_time[13] = '\0';
r_LCM_send_string(string_time, LCM_POSITION_BOTTOM);

/* Show "hh:mm:ss" on the bottom of LCD. */
convert_BCD_to_2chars(read_val.hour, &string_time[0]);
string_time[2] = ':';
convert_BCD_to_2chars(read_val.min, &string_time[3]);
string_time[5] = ':';
convert_BCD_to_2chars(read_val.sec, &string_time[6]);
string_time[8] = '\0';
r_LCM_send_string(string_time, LCM_POSITION_TOP);
}

static void convert_BCD_to_2chars(uint8_t bcd, uint8_t * const str)
{
    if (NULL == str)
    {
        return;
    }   
    *(str+0) = '0' + ((bcd>>4)&0xFU);
    *(str+1) = '0' + (bcd & 0xFU);
}

void r_LCM_send_string(uint8_t * const str, lcm_position_t pos)
{
int i;
uint8_t *p;

r_LCM_send_command(_0x80_LCM_COMMAND_SET_DDRAM_ADDRESS | pos);

for (i = 0, p = str; *p != '\0'; i++, p++)
{
if (i >= LCM_CONFIG_MAX_CHAR_PER_LINE)
{
/* The string length reached the maximum. */
break;
}
r_LCM_send_data(*p);
}
}

void main(void) {
        EI();                              /* Enable the interrupts. */
        r_LCM_init();    
        while (1U)
        {
            if (r_rtc_is_constperiod_flag_on())
            {
                RTCMK = 1U;                         //interupt disable
                r_rtc_display_current_time();             
                RTCMK = 0U;                       //interupt enaable        
        }
    }
}
 
Last edited by a moderator:

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
15,731
Helped
5,069
Reputation
10,163
Reaction score
4,924
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
133,219
You didn't mention what the LCD controller. Have you configured it correctly and checked the offset to the start of the second line is correct. The initialization and LCD address map varies from one controller to another.

Brian.
 

    jack1998

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top