jack1998
Junior Member level 2
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:
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: