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

RS232 problem 16F877a and Max232

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



Joined: 13 Sep 2008
Posts: 3

View user's profile Send private message

RS232 problem 16F877a and Max232
PostPosted: Sat Sep 13, 2008 11:06 am     Reply with quote

I am having problems with the RS232 connection.
I have a 16f877a chip connected to max232 chip for serial communications.
The program sends the information correctly to the hyper terminal. But sending bytes from the hyperterminal to the chip does not work.
I don't know if it's a software or a hardware problem. Could someone direct me to figuring out the solution.

here is the code i am using
Code:

//#include <16F877A.h>
#device adc=10
#use delay(clock=20000000)
#fuses NOWDT,HS, BROWNOUT, LVP
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3)

void HeartBeat(unsigned int beat)
{
   if( beat%2 == 0)
   {
      output_d(0x01);
   }
   else
   {
      output_d(0x00);
   }
     delay_ms(1000);

}

void main()
{
   int status;
   char value;
   unsigned int i;

   setup_adc_ports(A_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   set_tris_d(0x00);
   output_d(0x01);

   do
   {
      printf("Testing\r\n");
      printf("%u\r\n",i);
      i++;

      printf("Write Something\r\n");

      value = getch();
      putc(value);

      //HeartBeat
      HeartBeat(i);

   }while (TRUE);

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 13, 2008 11:29 am     Reply with quote

Try using a simple test program. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=32631&start=1

Notice the test program has the ERRORS parameter in the #use rs232()
statement. Put that in all your programs.

Also, are you using a Low Voltage Programmer ? You have the LVP fuse
set. That fuse should only be set if you have an LVP programmer, which
are rare, and homebuilt.
mohanade



Joined: 13 Sep 2008
Posts: 3

View user's profile Send private message

PostPosted: Sun Sep 14, 2008 10:18 am     Reply with quote

Thanks.. i fixed the fuses and now it works.
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