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

16F88 RS232 don't receive data.

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







16F88 RS232 don't receive data.
PostPosted: Tue Nov 15, 2005 3:14 am     Reply with quote

Hello everybody here, how are you? ;) I am looking for some "inspired" sould that can help me with this dissapointing problem :P.

I am not a begginer in the microcontrollers world, and this is getting me scary in some way, because the troubleshotting code is so easy and well, I will describe the problem.

I am working in a project that used a 16f628, and I decided to start with the new and more powerfull replacement in his category, the 16f88, and baby, after the switch I lose the rs232 communications.

I am using a max232 and is working ok, because I switch tx & rx to a 16f876 that is in the same protoboard, and works ok, (the circuit uses a 16f876 and a 16f88).

I can send data from the 16f88, but not receive that, but is so strange, the rx pin goes low all the time (in the 16f876 is high) and if I see the signal using a scope I see a 0v signal most of the time, except when I am sending data from the pc, in which case I see small variatons (the square wave) of 200 millivolts only. If I do the same test procedure in the 16f876 I see 5v most of the time in the rx line and goes to 0v when I am sending data from the pc.

I think that it must be a problem of the fuses, of the configuration, of my code or the compiler, I hope that the compiler does his work ok, but nowadays I did not trust in my shadow ;). This is my first attempt with a 16f88 and I don't know if I am configuring ok the system clock, the different options of the code, and maybe I am making a mistake, really I dont know what I am doing bad.

Here you have the code, its so simple because I started a new project for testing the communications, so please if someone can take a quick look and ... ;) :

(Thanks in advance, best wishes, and sorry for my bad english ;) )
(Compiler version 3.227)

---------------------------------------------------------------------
[Module.h]
----------------------------------------------------------------------

Code:
#include <16F88.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES PUT                      //Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled

#use delay(clock=8000000)
#use rs232(baud=19200,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8,stream=HW_RS232,errors)


---------------------------------------------------------------------
[Module.c]
----------------------------------------------------------------------
Code:

#include "Module.h"


void main()
{
   
   int8 iChar='a';
   int8 iRecv;

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   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);
   setup_oscillator(OSC_8MHZ|OSC_INTRC);
   
   delay_ms( 100 );
   
   fprintf( HW_RS232, "Starting ...\n\r" );
   
   
   while ( 1 )
   {
      if ( kbhit( ) )
      {
         iRecv = fgetc( HW_RS232 );
         
         fprintf( HW_RS232, "\n\rReceived: [ %c - %02X ] \n\r", iRecv, iRecv );
      }
     
      fprintf( HW_RS232, "%c", iChar++ );
     
      delay_ms( 250 );
   }

}
Ttelmah
Guest







PostPosted: Tue Nov 15, 2005 5:29 am     Reply with quote

Try adding:
#bit B2TRIS=0x86.2
in the definitions,

Then after the initialisation, but before your first printf, add:

B2TRIS=1;

Unfortunately, some compiler versions, set the TRIS incorrectly for the receive pin, leaving it defined as an output, which then stops the data being received.

Best Wishes
beth
Guest







Heyyyy it worksssss.
PostPosted: Tue Nov 15, 2005 10:37 am     Reply with quote

Ttelmah, thanks for your help, it works at the first try. There is a beer waiting for you here at Spain ;).

Again a lot of thanks. Best regards ;).
Ttelmah
Guest







PostPosted: Tue Nov 15, 2005 11:21 am     Reply with quote

Thanks.
Glad it worked. :-)

Best Wishes
guest
Guest







same problem
PostPosted: Tue Aug 01, 2006 5:48 pm     Reply with quote

I have a similar problem. I can transmit data from the pic to the pc correctly. but when I try the reverse I can never get the pic to pause for my input.

I have verified the hardware using another compiler. (oshonsoft pic simulator)

Quote:

Try adding:
#bit B2TRIS=0x86.2
in the definitions,

Then after the initialisation, but before your first printf, add:

B2TRIS=1;


I tried this and I could not get any output from the pic. (I am using a 16F648A)

I only set up the serial port using #use_rs232. Do I add the B2TRIS=1 right at the begning of the program?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 01, 2006 5:54 pm     Reply with quote

Make a test program similar to the one shown in this thread.
See if it works.
http://www.ccsinfo.com/forum/viewtopic.php?t=25130
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