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

pic18f4550 and dspic30f3011 cant communicate

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



Joined: 15 Jul 2012
Posts: 2

View user's profile Send private message

pic18f4550 and dspic30f3011 cant communicate
PostPosted: Sun Sep 30, 2012 3:55 pm     Reply with quote

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: 1334

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 8:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 08, 2012 5:25 am     Reply with quote

Thanks for your answer, it works successfully.
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