CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CCS Example on Real Time Interfacing: Can Anyone Explain

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
New_Convert
Guest







CCS Example on Real Time Interfacing: Can Anyone Explain
PostPosted: Tue Feb 10, 2004 9:35 pm     Reply with quote

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








PostPosted: Tue Feb 10, 2004 11:10 pm     Reply with quote

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'.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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