Serin Serout


Closed Thread
Results 1 to 4 of 4

Thread: Serin Serout

  1. #1
    Join Date
    Sep 2008
    Posts
    6

    Default Serin Serout

    I'm trying to get serout data to go right back into the same pic 16F688 on another pin with a wire connecting the two. The serin command doesn't seem to work, but I have no way of testing it other then trying to make the light blink on/off which it doesn't unless I comment out the serin command. With the code below, the light never comes on.

    'Port C.0 and C.1 are connected with a wire.

    CMCON0=%00000111
    ANSEL=%00000000
    TRISC=%00000010

    INCLUDE "modedefs.bas"
    n VAR BYTE
    m VAR BYTE

    loop:
    PORTC.2=1 ' Turn off LED connected to PORTC.2
    n = 12 ' Value to Send out Serial Port - Any old number will do.
    SEROUT PORTC.0,T2400,[n]
    Pause 1000 ' Delay for 1 seconds

    m = 0
    SERIN PORTC.1,T2400,m
    If m=0 then PORTC.2=0 'Turn on LED connected to PORTC.2
    Pause 3000 ' Delay for 3 seconds

    Goto loop ' Go back to loop and blink LED forever
    End

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    SEROUT is a software, bit banged command...

    SERIN is a software, bit banged command...

    So, unless you live where the laws of physics differ than the rest of the world, and those electrons (and/or charges) run a lot slower than the rest of the world and introduce an electrical delay of 1+ seconds along your loop of wire connecting PortC.0 and PortC.1......blah blah blah...

    Well, suffice to say, by the time your program gets down to the SERIN statement, the signals from the SEROUT statement have been gone for a little over 1 second...
    Last edited by skimask; - 29th September 2008 at 03:54.

  3. #3
    Join Date
    Sep 2008
    Posts
    6

    Default

    Got it. So that means I can never use delay's in code if I'm trying to use ports to receive serial data because that data could easily come in when the pic is processing the delay. Is this correct?

    Granted I would never use the pic this way, but I was trying to test my understanding of the programming. I thought specialized code somehow ran in the background and had buffers to store data while it was doing something else. Now I know this isn't true. Do the hardware UART's have this ability however since they have separate hardware to handle the behind the scenes processing?

    Also if I use a one direction radio link from one processor to another using built in UART's will it work. I'm not sure if UART's have to work bidirectionally to transmit and receive to verify data.
    Last edited by docaberle; - 29th September 2008 at 14:13.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by docaberle View Post
    Got it. So that means I can never use delay's in code if I'm trying to use ports to receive serial data because that data could easily come in when the pic is processing the delay. Is this correct?
    Pretty much.
    PICs don't multi-task in the sense that they don't multi-thread. The best you'll get out of a PIC is really fast time-slicing.

    Do the hardware UART's have this ability however since they have separate hardware to handle the behind the scenes processing?
    Yes, the UARTs have they're own hardware, but you still have to write the code to actually give (or take) the data to the UART for the UART to send and/or receive.

    I'm not sure if UART's have to work bidirectionally to transmit and receive to verify data.
    UART = Universal Asynchronous Receiver/Transmitter

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  4. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts