|
|
View previous topic :: View next topic |
Author |
Message |
New_Convert Guest
|
CCS Example on Real Time Interfacing: Can Anyone Explain |
Posted: Tue Feb 10, 2004 9:35 pm |
|
|
Here's a snippet of code from the CCS Exercise book.
I can't see at any stage this code can get a character 'S' (the 4th last line here).
So, I don't quite understand how the statement
if(kbhit() && (getc() == 'S'))
could evaluate to TRUE.
I know this sounds simple to most of you here. That's why I'm turning to you guys.
#include <protoalone.h>
#include <nju6355.c>
#include <bcd.c>
void set_time()
{
int hour, min;
printf("\r\nHour: "); hour = get_bcd();
printf("\r\nMin: "); min = get_bcd();
rtc_set_datetime(0,0,0,0,hour,min);
}
void main()
{
int hour,min,sec,last_sec;
rtc_init();
while(1)
{
rtc_get_time(hour, min, sec);
if(sec != last_sec)
{
printf("\r\n");
display_bcd(hour); putc(':');
display_bcd(min); putc(':');
display_bcd(sec);
last_sec = sec;
}
if(kbhit() && (getc() == 'S'))
set_time();
}
} |
|
|
Guest
|
|
Posted: Tue Feb 10, 2004 11:10 pm |
|
|
That is if it has received an S from the UART.
kbhit checks for a new character in the receive buffer, then checks if it is an 'S'. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|