Master to slave 16F767


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Here is an idea.

    In this block:
    Code:
    loop:
    RSIn Wait("SLAVE"), value
    If value = 0 Then
    GoTo loop
    Else
    GoSub charin ' Get a character from serial input, if any
    EndIf
    Turn the hardware PWM off. Turn it on after the correct serial command is received.
    Or make all of the LED pins LOW in the above.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's a potential stack overflow here
    Code:
    loop:
    RSIn Wait("SLAVE"), value
    If value = 0 Then
    GoTo loop
    Else
    GoSub charin ' Get a character from serial input, if any
    EndIf
    
    charin:
    There's no return in your code to handle it, the only one you have do the PWM, so if the value <>0, yes it will perform the Charin procedure... but you never POP the stack, after 2-3 time, yes indeed, your program may behave in a weird way. Try this...
    Code:
    loop:
    RSIn Wait("SLAVE"), value
    If value = 0 Then GoTo loop
    
    charin:
    Also, you want to make sure that your Serial dataline is noise free and idle at the right level if both device are disconnected.
    Last edited by mister_e; - 30th May 2008 at 17:24.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Thanks for the tips, I originally had similar code under the routine "loop" which also failed to work, but I'll try again and let you know.

    Cheers

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sachymo View Post
    Thanks for the tips, I originally had similar code under the routine "loop" which also failed to work, but I'll try again and let you know.
    Cheers
    http://www.picbasic.org/forum

    Good luck getting any of the follow lines/commands to compile under PBP...

    Device 16F767
    Dim whatever As something
    Declare anything_at_all
    RSIn Wait("For it to compile in PBP"), value
    X = 'until you get to the right forum'
    DelayMS X

Similar Threads

  1. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  2. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  3. PIC master slave howto
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th September 2007, 22:35
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. Replies: 2
    Last Post: - 10th June 2005, 02:34

Members who have read this thread : 0

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