12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    I've just spent two hours working on a post which I'm not going to post for the minute.

    However Question:

    How does:
    Code:
    DAT_OUT.0[1]
    work? Or were do I look for the solution, is it in the manual? (I'd rather try and find the answer) if I can't I'll ask

    The whole piece of code is:
    Code:
    DAT_OUT.0[1]=~GPIO.3
    I think the
    Code:
    ~GPIO.3
    part simply sends to GPIO.3

    From the manual:

    If you don't want MicroCode Studio to interpret a control sequence, but rather send it as normal characters, then just use the tilda symbol (~) in front of the $ or # symbol. For example, letter ~#9712345 would be sent as letter #9712345.
    Have I got that bit right?

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    (I'd rather try and find the answer) if I can't I'll ask
    COOL!!!

    "~" Look at the table under Math Operators 4.17 in the PBP manual.

    And these may help.
    http://www.picbasic.co.uk/forum/showthread.php?t=544
    http://www.picbasic.co.uk/forum/show...1955#post91955
    http://www.picbasic.co.uk/forum/show...&p=189#post189

    You may want to set up a little test program and send values to a LCD or something to play with this.
    Last edited by mackrackit; - 14th November 2010 at 23:07.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    You may want to set up a little test program and send values to a LCD or something to play with this.
    I will, the LCD's been looking a little lonely lately. I'll let you know how I get on.

    Cheers mackrackit, you're a star.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Code:
    ~ Bitwise NOT
    So it's a Bitwise NOT then (well I've never heard of that one before, I'll get straight on it)

    And not:

    If you don't want MicroCode Studio to interpret a control sequence, but rather send it as normal characters, then just use the tilda symbol (~) in front of the $ or # symbol. For example, letter ~#9712345 would be sent as letter #9712345.
    Like I thought it was. I can be almost dangerous with my assumptions sometimes

    Dave

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    I'm jumping in here.... The docs you've quoted is the docs for MicroCodeStudio, specifically its built in terminal emulator where the ~ means what you've quoted.

    But in the PBP language ~ means bitwise NOT, negate or invert - whatever you like.
    Code:
    GPIO.0 = ~GPIO.1       'Set GPIO.0 to the inverted state of GPIO.1
    /Henrik.

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    Yes, NOT GATE or inverted output, here's a Wiki link for any other newbies:

    http://en.wikipedia.org/wiki/Inverter_(logic_gate)

    Like I said in my post above, it's easy to jump to the wrong conclusions(that's why I appreciate your and mackrackit's help so much)

    Speaking of help, I blew the dust of the old LCD and ran a modified program from mackrackits link:

    Code:
    MyVAR VAR BYTE
    Mybyte var byte
    Mybit VAR bit
    
    LET MyByte = 7
    
    For MyVar = 0 to 7
    MyBit = MyByte.0(MyVar)
    LCDOut $FE,1,"Bit ",#MyVar,"=",#MyBit
    Pause 2000
    Next MyVar
    When I ran it, Bits 0-1-2 were 1's the rest 0's following the pattern for Bin 7. So onto Bruce's code below:

    Code:
    ' Only DAT_OUT bits 1 and 2 are used. We add a few 1's in bit
        ' positions 0,3,5,7 to balance out the data packet being sent.
        DAT_OUT = %10101001
        ' Get data on button inputs & invert 0's to 1's
        DAT_OUT.0[1]=~GPIO.3
        DAT_OUT.0[2]=~GPIO.4
        INTCON.0 = 0  ' Clear int on change flag
          
        ' Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2)
    Well the checksum would be two BYTES of:
    Code:
    DAT_OUT = %10101001
    With bits 1 & 2 being 0's (not inverted).....I think.


    Code:
    DAT_OUT = %10101001  DAT_OUT.0[1]=~GPIO.3 DAT_OUT.0[2]=~GPIO.4
    Would mean (I think again) bit 1 & 2 would invert to a 1 in the DAT_OUT_BYTE. Or saying that maybe it's only bits 1 & 2 that are inverted and sent. Mm, not sure but I'll go with the first option.

    Tin hat on, duck, am I close? (if not, just say so and I'll carry on thinking / reading).

    Dave
    Last edited by LEDave; - 15th November 2010 at 21:44.

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


    Did you find this post helpful? Yes | No

    Default

    Tin hat on
    I wear one made of aluminum foil...

    Code:
    IF (GPIO.3=1) AND (GPIO.4=1) THEN
    Because of this both bits in question are "1" when not pressed. So they will invert to "0".
    If the thing was not sleeping that is.

    But wait...
    Code:
    DAT_OUT = %10101001
    They are "0"...

    What if one of the buttons are pressed?

    In the end, all eight bits of DAT_OUT are sent.

    Yes, I am being a cryptic smart _ _ _.
    Dave
    Always wear safety glasses while programming.

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