RF12 module need to convert some C to Basic


Results 1 to 40 of 44

Threaded View

  1. #15
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: RF12 module need to convert some C to Basic

    Nops in this function are a delay. The function (subroutine as you worked out) sends a single zero value out of the SPI bus.
    If you were to set SCK low, and then high again in the very next instruction, the receiving device might miss the signal.
    Especially if the external device runs slower than the transmitting device. You can use @nop in PBP.

    Since there are several flavours of SPI, it would be better to reproduce this then use PBP SHIFTOUT (unless it’s already working).
    They are really only turning two port bits on & off.

    Code:
    writezero:
    portb.something = 0’ clear SPI data
    portb.something = 0’ clear clock pin, the receiver will look at the value of the SPI data bit now.
    delay
    portb.something = 1’ set the clock pin, the receiver will look for the next bit on the next rising edge (next time you call this function, or the writeone function).
    Code:
    void Write0( void )
    {
      SDI=0;
      SCK=0;
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      NOP();
      SCK=1;
      NOP();
    }
    Last edited by Art; - 8th October 2016 at 10:50.

Similar Threads

  1. Version Control
    By btaylor in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 16th October 2011, 17:12
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Replies: 1
    Last Post: - 27th July 2008, 06:14
  4. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  5. convert Basic Stamp2 (BS2) => Pic
    By bs2rdu in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th September 2005, 19:55

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