Bitwise not working


Closed Thread
Results 1 to 15 of 15

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default It needs & and after needs |

    Thanks everyone for the response.

    Well sayzer gave me the kick-start!

    What I was needed was to keep the upper bits while setting or reseting the lower according to the counter in the for - next loop. This is done first by clearing the lower bits, then OR-ing with the new value. I was too tired to see it immediatly. But, thanks for the try...

    The new code should look like this:

    for i=240 to 250
    temp=portb
    temp=temp & $F0
    temp=temp|i
    portb=temp
    pause 1000
    next i

    Thanks again,

    Ioannis

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE OSC 20
    DEFINE LOADER_USED 1
    RCSTA = $90   ' Enable serial port & continuous receive
    TXSTA = $20   ' Enable transmit, BRGH = 0
    SPBRG = 64    ' 19200 Baud @ 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    
    PORTB=0
    TRISB=%11110000
    i     var byte
    Temp  var byte
    
    Hserout ["***** Waiting PORTB.7 = 0 *****",13,10]
    While PORTB.7=1 : wend
    
    hserout ["------------------------Start",13,10]
    for i = 0 to 15
      PORTB=i
      Temp=PORTB
      hserout ["PORTB=",bin8 temp,13,10]
      next
    hserout ["------------------------Stop",13,10]          
    
    Spin: goto Spin
    if i hold PORTB.7=0

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1137&stc=1&d=116117525 3">
    Attached Images Attached Images  
    Last edited by mister_e; - 18th October 2006 at 14:41.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    looks like the attachement didn't work...

    this is the copy/paste
    Code:
    ***** Waiting PORTB.7 = 0 *****
    ------------------------Start
    PORTB=01110000
    PORTB=01110001
    PORTB=01110010
    PORTB=01110011
    PORTB=01110100
    PORTB=01110101
    PORTB=01110110
    PORTB=01110111
    PORTB=01111000
    PORTB=01111001
    PORTB=01111010
    PORTB=01111011
    PORTB=01111100
    PORTB=01111101
    PORTB=01111110
    PORTB=01111111
    ------------------------Stop
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. 16F877A with 20MHz XTAL not working?
    By ustredna in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th August 2011, 16:04
  2. 2x16 lcd not working with pic16f72
    By vu2iia in forum Schematics
    Replies: 4
    Last Post: - 16th February 2011, 15:59
  3. Blink.Bas on 18f45k20 Newbie seeks working example.
    By DiscoEd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 04:36
  4. Pic 16 F628A not working
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th March 2009, 13:26
  5. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 13:25

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