Menu

Serial between PICs

Help
2008-03-14
2013-05-30
  • Nobody/Anonymous

    Hey guys:  Here's my deal.  I need to send data between 2 PIC12f675s.  I tried the serial examples but can't get em to work.    Can someone please post an example for both sender and receiver?  All I need to send is one byte.  Thanks lots... Cathy

     
    • Hugh Considine

      Hugh Considine - 2008-03-19

      What clock speed are the 12F675s running at? The serial routines don't tend to work too well on slower chips, especially at the 9600 bps used in the examples. I often use the routines at 2400 bps and they seem to work okay.

      If that still doesn't work, please let me know and I'll write some new code. I've got some Manchester code routines and some remote control routines in the works, either of which might be better.

       
    • Nobody/Anonymous

      No, I couldn't get it to work at any baud rate.  I am using the 4MHz internal oscillator.  I also tried "1+WaitForStart" where needed and that didn't help.  Below is what I am doing. 

      Thanks

      #CHIP 12F675, 4

      #config OSC = int, MCLR = OFF

      #define StartUpDelay 10 ms

      Dim Counter as Byte

      DIR GPIO.0 OUT

      Startup:
      Wait StartUpDelay

      InitSer (1, r1200, 1, 8, 1, none, normal)

      Main:
      For Counter = 1 to 250
          SerSend (1, Counter)
          Wait 800 ms
      Next
      Goto Main

      #CHIP 12F675, 4

      #config OSC = INT, MCLR = OFF

      #define StartUpDelay 10 ms

      Dim Timed as byte

      DIR GPIO.0 IN

      Startup:
      Wait StartUpDelay

      InitSer (1, r1200, 1, 8, 1, none, normal)
      Timed = 0
      Main:
        SerReceive (1, Timed)
        Wait 100 ms
        Goto Main

       
    • Hugh Considine

      Hugh Considine - 2008-03-19

      You need to tell GCBASIC which pin to use for the serial routines.

      On the sender, add these lines:
      #define SendAHigh Set GPIO.0 On
      #define SendALow Set GPIO.0 Off

      And on the receiver, these lines:
      #define RecAHigh GPIO.0 On
      #define RecALow GPIO.0 Off

      On the sender the constants are used to give the command to send a high, and the command to send a low. On the receiver, they give a condition that is true when a high is being received, and a condition that is true when a low is being received.

      Hopefully this works!

       
    • Nobody/Anonymous

      Tried that and it didn't work.  Both chips do other things fine so I would believe they are working fine.  Should one side be set normal and one invert?

      Thanks!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.