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 - HARD X SOFT

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



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

RS232 - HARD X SOFT
PostPosted: Thu Sep 06, 2007 8:53 am     Reply with quote

Hi all , I need some help regarding the use of the RS232.
I'm using a CCS 4.14 for a pic16f628a.

When using the hardware to do a serial communication with the system I have to control (another PIC that I can't change the code) it works just fine !
But when I change for the software communication ( using FORCE_SW in the #use_rs232) or using Pin that dos not have support for hardware USART the communications it just do not work.

What's worst about it that this is happening in the PROTEUS simulation and in the real actual hardware.

But if i plug the rx/tx in a PC ( or in a virtual term in PROTEUS) I get the right answer.

What I mean is : I'm sending the correct data. ( theses is what I tested and checked in a osciloscope)

But the other system cant understand me.

IF i use the hardware USART he can.
If i don't he can't.


---

Thanks in advance
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Sep 06, 2007 10:36 am     Reply with quote

It would be nice if we can see some code to help you.


Humberto
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 1:05 pm     Reply with quote

Ok.

This code works :

Code:

#include <16F628A.h>
#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 BROWNOUT                 //Reset when brownout detected
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD                    //No EE protection
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_b2,rcv=PIN_b1,bits=8)// HARDWARE
#use I2C(master, sda=PIN_A0, scl=PIN_A1, fast=100000)


boolean key_present;
unsigned char comando,dado;
void comunica_teclado()// KEYBOARD
{
   unsigned char a;
   do
   {
      a=getc();   
      comando=getc();
      dado=getc();
   }  while(a!='@');   
   //espera receber @ na serial
   if(comando == 'W')
   {
     putc(0x01);     
   }
   else if(comando == 'Q')
   {
      printf("@QCAA");
      putc(0);
      key_present=1;
   }
   else if( comando == 'R')
   {
       putc(0x02);
   }
}

void main()
{
   port_b_pullups( true); // LIGA PULLUPS DA PORTA B
   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(False);
   printf("inicio");
   for(;;)
   {
      comunica_teclado();
   }
}
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 1:11 pm     Reply with quote

And this does not.

Code:
#include <16F628A.h>
#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 BROWNOUT                 //Reset when brownout detected
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD                    //No EE protection
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_a2,rcv=PIN_a3,bits=8)//  OTHER PINS
#use I2C(master, sda=PIN_A0, scl=PIN_A1, fast=100000)


boolean key_present;
unsigned char comando,dado;
void comunica_teclado()// KEYBOARD
{
   unsigned char a;
   do
   {
      a=getc();   
      comando=getc();
      dado=getc();
   }  while(a!='@');   
   //espera receber @ na serial
   if(comando == 'W')
   {
     putc(0x01);     
   }
   else if(comando == 'Q')
   {
      printf("@QCAA");
      putc(0);
      key_present=1;
   }
   else if( comando == 'R')
   {
       putc(0x02);
   }
}

void main()
{
   port_b_pullups( true); // LIGA PULLUPS DA PORTA B
   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(False);
   printf("inicio");
   for(;;)
   {
      comunica_teclado();
   }
}
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 1:12 pm     Reply with quote

This also does not work:

Code:
#include <16F628A.h>
#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 BROWNOUT                 //Reset when brownout detected
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD                    //No EE protection
#use delay(clock=20000000)
#use rs232(baud=9600,FORCE_SW,parity=N,xmit=PIN_b2,rcv=PIN_b1,bits=8)// FORCED SOFTWARE
#use I2C(master, sda=PIN_A0, scl=PIN_A1, fast=100000)


boolean key_present;
unsigned char comando,dado;
void comunica_teclado()// KEYBOARD
{
   unsigned char a;
   do
   {
      a=getc();   
      comando=getc();
      dado=getc();
   }  while(a!='@');   
   //espera receber @ na serial
   if(comando == 'W')
   {
     putc(0x01);     
   }
   else if(comando == 'Q')
   {
      printf("@QCAA");
      putc(0);
      key_present=1;
   }
   else if( comando == 'R')
   {
       putc(0x02);
   }
}

void main()
{
   port_b_pullups( true); // LIGA PULLUPS DA PORTA B
   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(False);
   printf("inicio");
   for(;;)
   {
      comunica_teclado();
   }
}


Last edited by igorbb on Thu Sep 06, 2007 1:14 pm; edited 1 time in total
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 1:14 pm     Reply with quote

That's why I'm thinking the problem is software comunication library.
Every time it uses a software for some reason the other system does not understand him.

But I've checked and thereis data going on the TX pin.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 06, 2007 1:39 pm     Reply with quote

Try a very simple program, as shown below. Then try it with FORCE_SW.
Code:

#include <16F628A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, ERRORS)

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

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

Note that this program uses NOLVP. That's important. The LVP fuse
is only used if you have a LVP programmer. 99% of all programmers
use High Voltage mode, and therefore must use the NOLVP fuse setting.

Quote:
I'm using a CCS 4.14 for a pic16f628a.

There is no version 4.14. Post your true compiler version. See this list:
http://www.ccsinfo.com/devices.php?page=versioninfo

If you really have vs. 4.014, then I suggest that you upgrade to a later
verson. Vs. 4.014 will have many bugs in it. The bugs could be the
reason your programs don't work. (Besides using the LVP fuse).
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 1:57 pm     Reply with quote

Its 4.014. Sorry for that.

I will try the NOLVP.

And the problem its not the communication by it self .
When I use in a hyperterminal it works just fine. ( Using HARD or SOFT communication)


But my system ( other PIC that I can't change nothing on the code) just understand when I use Hardware communication!

I will try with other CCS too.


--
Thanks for the help
;)
I will keep you updated with the results.
igorbb



Joined: 06 Sep 2007
Posts: 7
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 06, 2007 2:19 pm     Reply with quote

Also tryed with the CCS 3.249

And I got the same error.

Its very strange cause in the hyperterminal Its the same for the both case ( With the software and hardware) But my system just understand when i use hardware.

=/
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 06, 2007 2:30 pm     Reply with quote

What are the connections to your other PIC ? (For Tx and Rx)


Do the Tx and Rx signals go through a MAX232 chip ?
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