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 CCS Technical Support

hyperterminal and lcd

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



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

hyperterminal and lcd
PostPosted: Tue Apr 21, 2009 3:05 pm     Reply with quote

Working just with hyperteminal (windows) the code below work perfectly, but when I tried to implement a push button and an lcd together with hyperterminal...it doesn't work. I mean, when I press push button nothing is sent to lcd.
If I take out the if using getc then if I press push button the message is displayed on the lcd.

Here is the code.

Thank you in advance.
Code:
#include <16F877.h>
#use delay(clock=4000000)
#fuses HS, NOWDT,PUT,BROWNOUT,NOLVP
#use rs232(baud=9600, parity=N, xmit=PIN_C6,rcv=PIN_C7)//Configura serial
#include <flex_lcd420.c>

#define LED0 PIN_C0
#define LED1 PIN_C5
#define LED2 PIN_D2
#define botao PIN_E0


char dado;
main(){
   lcd_init();
   delay_ms(100);
   printf("Começando o Programa...");
   while(true){

if (input(botao)==1){
delay_ms(1000);
printf(lcd_putc,"Ligado");
         output_high(LED2);
         delay_ms(100);
                 }

if (input(botao)==0){
         output_low(LED2);
         delay_ms(100);
                 }

if (getchar()=='1'){
         printf("MENU 1!!!");
         output_high(LED1);
         delay_ms(100);
                 }
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 21, 2009 3:26 pm     Reply with quote

Describe the external circuit for your push-button.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 21, 2009 3:32 pm     Reply with quote

The getchar function is blocking, it waits till a character is received on the serial port, leaving no time for processing the key inputs.

change:
Code:
if (getchar()=='1'){
to:
Code:
if (kbhit)
{
  if (getchar()=='1'){
The kbhit function will test if a new character is waiting to be processed and only then calls the blocking getchar function.
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

hyperterminal and lcd
PostPosted: Tue Apr 21, 2009 3:52 pm     Reply with quote

ckielstra..it work perfectly...thank you very much for your help and cooperation..

nina
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