|
|
View previous topic :: View next topic |
Author |
Message |
tantan
Joined: 15 Jul 2012 Posts: 2
|
pic18f4550 and dspic30f3011 cant communicate |
Posted: Sun Sep 30, 2012 3:55 pm |
|
|
Hi everyone. I have a problem. I can't communicate between dspic and 18F4550. When I try to communicate between two 18F4550, it worked. But I can't communicate with dspic. There are my code. What can I do ? Code: |
#include <18F4550.h>
#fuses HS,NOWDT,PROTECT,NOLVP,NODEBUG,PLL5,CPUDIV1,VREGEN
#use delay(clock=24000000)
#use rs232(baud=1200,parity=N,xmit=PIN_c6,rcv=PIN_a3,bits=8,stop=1)
void main()
{
while(1)
{
output_high(pin_a3);
output_low(pin_a4);
if(input(pin_a5))
{
while(input(pin_a5))
{
putc('X');
delay_ms(250);
}
}
}
} |
Code: | #include <30F3011.h>
//#device ICD=TRUE // For using the debugger, un-comment
#use delay(crystal=24mhz)
// UART1A specifies the alternate UART pins Pin_C13, Pin_C14
// use UART1 to sprcify UART for pins Pin_F3, Pin_F2
#use rs232(baud=1200, UART1A)
void main() {
output_high(PIN_B3);
delay_ms(250);
output_low(PIN_B3);
delay_ms(250);
while (TRUE) {
output_high(PIN_B4);
output_low(PIN_B3);
if(getc()=='X')
{
output_high(PIN_B3);
output_low(PIN_B4);}
}
}
|
|
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1345
|
|
Posted: Mon Oct 01, 2012 8:10 am |
|
|
How can you tell it doesn't work. As soon as you toggle your LEDs for 'X', you toggle them right back immediately. The LEDs will appear to not change at all.
Also, you are not using the ERRORS option in your #use RS232() statement like you should be. Hardware can lockup otherwise. |
|
|
tantan
Joined: 15 Jul 2012 Posts: 2
|
|
Posted: Mon Oct 08, 2012 5:25 am |
|
|
Thanks for your answer, it works successfully. |
|
|
|
|
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
|