|
|
View previous topic :: View next topic |
Author |
Message |
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
18F6722 RS232 problem |
Posted: Mon Mar 19, 2012 12:32 am |
|
|
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
|
|
Posted: Mon Mar 19, 2012 2:41 am |
|
|
++++++++++++++++++
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
|
|
Posted: Mon Mar 19, 2012 4:42 am |
|
|
Try using UART1 and UART2 instead of specifying the pins.
RF Developer |
|
|
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
|
Posted: Tue Mar 20, 2012 1:54 am |
|
|
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 |
|
|
|
|
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
|