cannot find the reason for such a strange behavior


Results 1 to 18 of 18

Threaded View

  1. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,687


    Did you find this post helpful? Yes | No

    Default Re: cannot find the reason for such a strange behavior

    Richards code below shows (I think) the ~operator working but not really, at least not that I can see, in the exact way you're using it
    thanks for that henrik lets see if we can agree to the problem definition it's possible the badgers have moved the goalposts.

    my assumption is
    the elements of a byte array [of less than 256 bytes] are summed from the first element to the penulitmate element into a word var
    the low byte of this word var is inverted and placed into the last element.
    the allegation is that :-
    {note .w0 is the word sum of the array}
    Code:
    array[z] = ~w0   ;  where  w0 ia a word and the [byte]array is of z+1 elements
    can produce and incorrect result in that, when read back array[z] is always $fd
    or that
    IF I DO NOT INVERT THE BYTE VALUE THE CRC RECEIVED IS CORRECT
    which i assume to be
    Code:
    array[z] = w0.lowbyte  ; not inverted
    is correct where as

    Code:
    array[z] = w0.lowbyte
    array[z] = ~array[z]  ; inverted

    can produce and incorrect result in that, when read back array[z] is always $fd
    Last edited by richard; - 12th November 2016 at 03:49.
    Warning I'm not a teacher

Similar Threads

  1. Strange behavior on PORTB on a PIC18F26K20
    By Dosbomber in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th September 2016, 00:31
  2. Strange Behavior 12F1822
    By nobner in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 3rd February 2012, 09:11
  3. Strange LCD Behavior
    By chips123 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st November 2009, 01:48
  4. Strange behavior - PORTG.2, 18F8720
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th January 2009, 00:30
  5. Strange electrical behavior with PIC16F684
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 28th March 2008, 07:58

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