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

RS 232

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



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

RS 232
PostPosted: Tue Sep 25, 2007 3:07 pm     Reply with quote

i have made a crude laptimer that out puts the most recent 3 lap times and current lap time on a 4line lcd but the rs232 part is not outputting to the computer. the lap time resets and transmits on a button press

here is the code. i have connected TX(pin 25) to through a max 232 to the computers serial port.

Code:
#include <16F877a.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_b2,rcv=PIN_b1,BITS =8, PARITY=n, stop=2)
#include <Flex_LCD420.c>   

unsigned int8 msec, msec1, msec2, msec3;
unsigned int8 sec, sec1, sec2, sec3;
unsigned int8 min, min1, min2, min3;
unsigned int8 lap_num,but_state;

//===================================
void main()
{
lcd_init();
delay_ms(500);
printf(lcd_putc, "\f");
delay_ms(500);

   msec=0; sec=0; min=0; msec1=0; sec1=0; min1=0; msec2=0; sec2=0;
   min2=0; msec3=0; sec3=0; min3=0;
   lap_num =0;
   
while(1)
  {
  but_state = input(PIN_B5);
 
     if (but_state == 0)
      {
         delay_ms(10);
         msec++;
                 
            if (msec==100)
            { 
               sec++;
               msec=0;
               
               printf(lcd_putc, "\fCurrent Lap %02u:%02u" ,min,sec);
               printf(lcd_putc, "\nLap %02u   %02u:%02u:%02u" ,lap_num, min1,sec1,msec1);
               printf(lcd_putc, "\nLap %02u   %02u:%02u:%02u" ,lap_num-1,min2,sec2,msec2); 
               printf(lcd_putc, "\nLap %02u   %02u:%02u:%02u" ,lap_num-2,min3,sec3,msec3); 
            }
           
            if (sec==59)
            {
               min++;
               sec=255;
            }
      }
     
      if( but_state==1 )   //button PIN B5 goes high
      {
      printf("Lap %02u   %02u:%02u:%02u\n\r" ,lap_num+1, min,sec,msec);
     
         msec3=msec2; sec3=sec2; min3=min2;
         
         msec2=msec1; sec2=sec1; min2=min1;     
         
         msec1=msec;  sec1=sec;  min1=min;

         msec=0;      sec=0;     min=0;
         
         while(but_state == 1)      //waits for button PIN B5 to be go low
            {
               but_state = input(PIN_B5);
               delay_ms(1);
            }
           
         lap_num++;         
      }
  }
}


thanks
for any help
Ttelmah
Guest







PostPosted: Tue Sep 25, 2007 3:19 pm     Reply with quote

Er.
You have connected pin 25 to the MAX232, but told the code to use pin 35....
As an 'aside', do you really need to use 2 stop bits?. This means the data cannot be sent by the hardware UART, unless you start fiddling (send 9 bits, and set the 9th bit high).

Best Wishes
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Tue Sep 25, 2007 4:01 pm     Reply with quote

no i dont need the 2 stop bits i guess

yes i see its on b2 my mistake

cheers for the help
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