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

18F6722 RS232 problem

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



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

18F6722 RS232 problem
PostPosted: Mon Mar 19, 2012 12:32 am     Reply with quote

Dear Friends;

I am using 18F6722 microcontroller for 2 serial hardware ports.

I have made a simple program but it does not work correctly.
I really don't know the reason why.

Here is my code:
Code:

#include <18F6722.h>
#fuses HS,NOWDT,PROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N, XMIT=PIN_C6, RCV=PIN_C7,errors,bits=8,stream=s1)
#use rs232(baud=9600,parity=N, XMIT=PIN_G1, RCV=PIN_G2,errors,bits=8,stream=s2)

void main()
{
   while(1)
   {
      fprintf(s1,"Online\r\n");
      fprintf(s2,"Online\r\n");
      delay_ms(1000);
    }
 }
 


And this is the output I received on the terminal. Terminal stops receiving DATA after 2, 3 lines of DATA even if I am sending DATA with continuous loop and no DATA receive after the garbage. DATA..
\0Aine\0D
\0AOnline\0D
\0AOnline\0D
Ê‹«Onliÿ
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 2:41 am     Reply with quote


++++++++++++++++++
Spambot post removed. Sorry.

- Forum Moderator
++++++++++++++++++


Thanks;
I have just tried to use only one serial port and it is working fine with single serial port with RS485 IC

have a look:
Code:


#device ICD=TRUE
#fuses HS

#use rs232(baud=9600,parity=N, XMIT=PIN_G1, RCV=PIN_G2,errors,bits=8)

#fuses NOWDT

#use delay(clock=10000000)
//#use rs232(baud=9600,parity=N, XMIT=PIN_C6, RCV=PIN_C7,errors,bits=8,stream=s1)
#use rs232(baud=9600,parity=N, XMIT=PIN_G1, RCV=PIN_G2,errors,bits=8)//,stream=s2)

void main()
{
   //output_high(PIN_G0);
   //output_low(PIN_G0);
   while(1)
   {
      printf("online");
//      fprintf(s1,"Online\r\n");
//      fprintf(s2,"Online\r\n");
      delay_ms(1000);
      output_toggle(PIN_G0);
    }
 }


[/code]
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 4:42 am     Reply with quote

Try using UART1 and UART2 instead of specifying the pins.

RF Developer
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Tue Mar 20, 2012 1:54 am     Reply with quote

Thank you RF for your help.

I made a second hardware with the same controller and the same program is working with it.

There might be something wrong with RS232 IC or its connection in previous card. I am looking for it.

Thanks for everyone who helped me in my simple task.

Regards
Ashraf
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