RF12 module need to convert some C to Basic


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    It could be a timing issue. No time to check now. If anyone could?

    Ioannis

  2. #2
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default word to bit[16]

    I am just getting started on this again tonight...

    I the example from Skimask above, the variable CMD is I assume an array of 16 bits? so I should declare..

    Code:
    CMD  VAR  bit[16]
    Am I correct?


    My next question is how do I get my word variable into series of 16 bits?

    Code:
    dout = $D0F7
    
    for n = 16 to 0 step -1
      CMD[n] = %dout.15
      dout << 1
    next n


    Keep in mind I am almost certain that the above example will not work... It's just to show that I am trying, not just asking everyone else to make my project for me...

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    For this CMD[n] = %dout.15 try as:

    CMD.0[n] = %dout.15

    Ioannis

  4. #4
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default almost!

    My current attempt is....

    Code:
    cmd             var byte[15]
    dout = $C0F7
    
    ...
    
    lcdout $fe,$C0," "
    for n = 16 to 1 step -1
      CMD.0[n] = dout.15
      dout = dout << 1
      lcdout $fe,14,bin dout.15
    next n
    This results in ... 1000000111101110 ... and I want ... 1100000011110111 ...

    i.e. It has chopped the 1 off the start, and added a 0 on the end...

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Try this

    for n = 15 to 0 step -1

    Ioannis

  6. #6
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default whoops

    I just realised what I did...

    dout = dout << 1
    lcdout $fe,14,bin dout.15

    I was displaying the dout bit after it had shifted... Stupid me.. I swapped those 2 lines, and I know I am giving the right string of bits to the array...
    I'm trying to display the array to see if all those bits went in.. Something is not right tho.

    Code:
    n		        VAR	BYTE
    nn		        VAR	BYTE
    cmd                            VAR            BYTE[15]
    ...
    
    lcdout $fe,$C0," "
    for n = 15 to 0 step -1
      CMD.0[n] = dout.15
      lcdout $fe,14,bin dout.15
      dout = dout << 1
    next n
    
    lcdout $fe,$d4," "
    for nn = 0 to 15
      lcdout $fe,$14,cmd.0[nn]
    next nn
    This last bit where I try to display the cmd array just gives me garbage characters.
    Last edited by davewanna; - 10th June 2008 at 11:03.

  7. #7
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Still not working

    I have just read a very in depth post by Melanie about bits in bytes, and arrays etc...
    I think I understood most of it.. and have changed my code to....

    Code:
    n		        VAR	BYTE
    nn		        VAR	BYTE
    cmd                            VAR            BYTE[16]
    
    ...
    
    lcdout $fe,$C0," "
    for n = 15 to 0 step -1
      CMD[n] = dout.15
      lcdout $fe,14,bin dout.15
      dout = dout << 1
    next n
    
    lcdout $fe,$d4," "
    for nn = 0 to 15
      lcdout $fe,$14,cmd(nn)
    next nn
    However it still doesn't seem to have solved my problem. I am still getting the wierd character in the bottom lcdout array..

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