Weird code problem


Results 1 to 6 of 6

Threaded View

  1. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With EncodedData var word [4] you have 4 words total in the array.

    EncodedData[0]
    EncodedData[1]
    EncodedData[2]
    EncodedData[3]

    Now with;

    mydata [0]= "T"
    mydata [1]= "E"
    mydata [2]= "S"
    mydata [3]= "T"
    mydata [4]= "."

    If each byte in mydata gets encoded as 2 bytes, you're going to need more
    than 4 words or 8 bytes to store your encoded data in.

    So, when mydatactr is 4, and you jump to your encode routine;

    encodeddata.lowbyte[mydatactr]=manchesterword.lowbyte
    encodeddata.highbyte[mydatactr]=manchesterword.highbyte

    It's placing the encoded value outside your EncodedData word array. I.E. you
    now have two bytes of data in RAM out-of-bounds of your array.

    You mean you can't use a zero for an array pointer?
    You can, but you need to make sure you don't exceed the array boundary.

    A 4 word array only goes from 0 to 3. Not 0 to 4.
    Last edited by Bruce; - 15th March 2009 at 17:13.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Problem compiling EasyHID code
    By mindthomas in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th August 2010, 20:46
  2. MN1307 sample code problem
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th November 2008, 20:41
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. PIC18F got some weird problem?
    By NatureTech in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th February 2007, 16:18
  5. Servo Code problem
    By ALFRED in forum General
    Replies: 1
    Last Post: - 2nd March 2006, 03:30

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