Shake_ECET209
New Member
Hi Guys, I am making a RTC that displays military time at the push of a button. I am using the code from the RTC lab we did and adding the LCD screen, but the code uses the RS232, and instead i want to use the push buttons on the board to set the time/hr/min and then display that time in military time.
Can anyone help me remove the use of the RS232 in the code we have not gone over it yet and I am really not similar with it.
Also Do I only need to change the <16F88.h> header file in order to make it work for the 16f88??
Thanks guys any help is appreciated
Can anyone help me remove the use of the RS232 in the code we have not gone over it yet and I am really not similar with it.
Also Do I only need to change the <16F88.h> header file in order to make it work for the 16f88??
Thanks guys any help is appreciated
Code:
#if defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCH__)
#include <18F4520.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif
#define _USE_LCD_
#define CLOCKS_PER_SECOND 1000
#include <time.h>
#include <rtctimer.c>
#include <stdlib.h>
#include <input.c>
#if defined(_USE_LCD_)
#include <lcd.c>
#endif
void InitTime(void)
{
struct_tm t;
//tm_year is years since 1900.
printf("\r\nYear (0-99): ");
t.tm_year = (int16)get_int() + (int16)100;
printf("\r\nMonth (1-12): ");
t.tm_mon = get_int() - 1;
printf("\r\nDay (1-31): ");
t.tm_mday = get_int() - 1;
printf("\r\nHour (0-23): ");
t.tm_hour = get_int();
printf("\r\nMinute (0-59): ");
t.tm_min = get_int();
SetTime(&t);
printf("\r\n\n");
}
void main(void)
{
char tString[32];
int i = 0;
time_t tTime = 0;
#if defined(_USE_LCD_)
lcd_init();
#endif
printf("\r\n\nex_rtctimer\r\n\n");
InitTime();
#if getenv("CLOCK")==4000000)
setup_timer_2(T2_DIV_BY_1,250,4);
#elif getenv("CLOCK")==20000000)
setup_timer_2(T2_DIV_BY_4,250,5);
#else
#error Configure TIMER2 so it interrupts at a rate defined by CLOCKS_PER_SECOND
#endif
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
while(1)
{
tTime = time(NULL);
ctime(&tTime, tString);
printf("It is currently: %s\n\r", tString);
#if defined(_USE_LCD_)
lcd_gotoxy(1,1);
i = 3;
while(tString[i] != '\0')
{
lcd_putc(tString[i]);
i++;
}
#endif
delay_ms(1000);
}
}
Last edited: