help


Closed Thread
Results 1 to 9 of 9

Thread: help

  1. #1
    Join Date
    Aug 2007
    Posts
    3

    Default help

    how can i move bit 8 from wordA to bit 2 from wordB ?

  2. #2
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Without actually testing it... have you tried the following?
    Code:
    wordB.1 = wordA.7
    Like I said... haven't tried it, but Melanie referenced it in the following thread:
    http://www.picbasic.co.uk/forum/showthread.php?t=544
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    the format is correct but I would write it as

    Code:
    WordB.2=WordA.8
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    the format is correct but I would write it as

    Code:
    WordB.2=WordA.8
    Really? I thought bits in a variable were referenced starting @ 0.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Really? I thought bits in a variable were referenced starting @ 0
    me too - if you read the OP's post, he wanted to move bit 8 to bit 2 ... words go from 0-15
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    Join Date
    Aug 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Unhappy

    My question is, if the main program is too big, why delay the clock.

    '***** clockx.bas **********************
    hour var byte ' Define hour variable
    dhour var byte ' Define display hour variable
    minute var byte ' Define minute variable
    second var byte ' Define second variable
    ticks var byte ' Define pieces of seconds variable
    update var byte ' Define variable to indicate update of LCD
    i var byte ' Debounce loop variable

    ADCON1 = 7 ' PORTA and E digital
    Low PORTE.2 ' LCD R/W low = write
    Pause 100 ' Wait for LCD to startup

    hour = 0 ' Set initial time to 00:00:00
    minute = 0
    second = 0
    ticks = 0

    update = 1 ' Force first display

    ' Set TMR0 to interrupt every 16.384 milliseconds
    OPTION_REG = $55 ' Set TMR0 configuration and enable PORTB pullups
    INTCON = $a0 ' Enable TMR0 interrupts
    On Interrupt Goto tickint
    ' Main program loop - in this case, it only updates the LCD with the time
    mainloop:
    PORTB = 0 ' PORTB lines low to read buttons
    TRISB = $f0 ' Enable all buttons

    ' Check any button pressed to set time
    If PORTB.7 = 0 Then decmin
    If PORTB.6 = 0 Then incmin ' Last 2 buttons set minute
    If PORTB.5 = 0 Then dechr
    If PORTB.4 = 0 Then inchr ' First 2 buttons set hour

    ' Check for time to update screen
    chkup: If update = 1 Then
    Lcdout $fe, 1 ' Clear screen

    ' Display time as hh:mm:ss
    dhour = hour ' Change hour 0 to 12
    If (hour // 12) = 0 Then
    dhour = dhour + 12
    Endif
    ' Check for AM or PM
    If hour < 12 Then
    Lcdout dec2 dhour, ":", dec2 minute, ":", dec2 second, " AM"
    Else
    Lcdout dec2 (dhour - 12), ":", dec2 minute, ":", dec2 second, " PM"
    Endif
    update = 0 ' Screen updated
    Endif
    Goto mainloop ' Do it all forever
    ' Increment minutes
    incmin: minute = minute + 1
    If minute >= 60 Then
    minute = 0
    Endif
    Goto debounce
    ' Increment hours
    inchr: hour = hour + 1
    If hour >= 24 Then
    hour = 0
    Endif
    Goto debounce
    ' Decrement minutes
    decmin: minute = minute - 1
    If minute >= 60 Then
    minute = 59
    Endif
    Goto debounce
    ' Decrement hours
    dechr: hour = hour - 1
    If hour >= 24 Then
    hour = 23
    Endif
    ' Debounce and delay for 250ms
    debounce: For i = 1 to 25
    Pause 10 ' 10ms at a time so no interrupts are lost
    Next i
    update = 1 ' Set to update screen
    Goto chkup
    ' Interrupt routine to handle each timer tick
    disable ' Disable interrupts during interrupt handler
    tickint: ticks = ticks + 1 ' Count pieces of seconds
    If ticks < 61 Then tiexit ' 61 ticks per second (16.384ms per tick)

    ' One second elasped - update time
    ticks = 0
    second = second + 1
    If second >= 60 Then
    second = 0
    minute = minute + 1
    If minute >= 60 Then
    minute = 0
    hour = hour + 1
    If hour >= 24 Then
    hour = 0
    Endif
    Endif
    Endif
    update = 1 ' Set to update LCD
    tiexit: INTCON.2 = 0 ' Reset timer interrupt flag
    Resume
    End
    '************************************************* **
    Please help! [email protected]

  7. #7
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default ???

    Quote Originally Posted by kingek22 View Post
    My question is, if the main program is too big, why delay the clock.
    What does that have to do with this thread?
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  8. #8
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    me too - if you read the OP's post, he wanted to move bit 8 to bit 2 ... words go from 0-15
    We're on the same page. I guess the way I understood the question was bit 2 (mywordB.1) etc. Maybe I was overthinking the question.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  9. #9
    Join Date
    Aug 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    This is the program, and the question is the same: why delay the clock?
    My projekt consist two program, because two pic communicat with each other. this program, what i wrote is one of them.

    Thank you.
    Attached Files Attached Files

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