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

Receiving RS-232 Data From HyperTerminal (16F877A)

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 06, 2007 5:29 pm     Reply with quote

Try a very simple test program:
Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
char c;

while(1)
  {
   c = getc();
   putc(c);
  }


 
 
 
Jomile



Joined: 06 Nov 2007
Posts: 5

View user's profile Send private message

PostPosted: Wed Nov 07, 2007 12:09 pm     Reply with quote

Thanks for the code.
I implemented it and still had the same problem. It turned out that the development board that I am using had a resistor between the max chip and the port. I shorted it out and now its fine.

FOLLOW UP:
When I use your test code and the printf function i can send data the hyperterminal. But when I use the PIC Wizard to make a new project my text gets cut off. For example, if i call printf("start") I get "Sta" in HT. I do not have a wdt enabled. See code below.


MAIN.C
Code:
#include "C:\Program Files\PICC\Projects\11-7-07\main.h"
  #include <string.h>

void main()
{

   setup_adc_ports(AN0_AN1_AN3);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_CLK_DIV_4);
   setup_timer_0(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);

   // TODO: USER CODE!!
   printf("Start");

}


MAIN.H
Code:

#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES WRT_50%                  //Lower half of Program Memory is Write Protected

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
frequentguest
Guest







PostPosted: Wed Nov 07, 2007 12:25 pm     Reply with quote

Your PIC is going to sleep before it finishes transmitting. There is a hidden sleep instruction that is put at the end of main().

Put a while(TRUE); statement after your printf to keep this from happening.

Code:
printf("start");
while(TRUE);
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