Any chance of Life being easy?


Closed Thread
Results 1 to 5 of 5
  1. #1
    josegamez's Avatar
    josegamez Guest

    Cool Any chance of Life being easy?

    Hi everyone!

    I have been programming a PIC18F458 with PICBasic Pro and so far everything has gone nice and easy except for changing the oscillator configuration but I got the hang of that already. So I've been printing menus on an LCD, doing pauses, responding to keyboard interrupts, etc but I've now gotten to the point where I actually have to process data and bits. My question is: is there a way of working with groups of bits? (I haven't found anything on this subject in any book on PBP). What I mean is, is there the PBP equivalent for Verilog command lines that involve groups of bits such as PortA[3:1] for example? It would really make my life easier if I could do things like Datum[6:4] = 2 for example or others like IF PORTB[5:1]=3 THEN .... etc. But like I said I haven't seen anything on this anywhere.

    If it's not possible, is there at least a way to concatenate bits and stuff into variables without using OR masks? Thanks to all, I hope I was clear in my question because I need help with that. God bless you.

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


    Did you find this post helpful? Yes | No

    Smile

    Not quite as pretty as your verilog versions ... but should work

    ;Datum[6:4] = 2
    Datum.6=1
    Datum.4=0

    ;IF PORTB[5:1] = 3 THEN
    If (PORTB & $22) = $22 THEN

    EDIT:
    or
    Code:
    IF PORTB.5 = 1 THEN
      IF PORTB.1 = 1 THEN
      ENDIF
    ENDIF
    Last edited by paul borgmeier; - 2nd November 2006 at 04:47.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    josegamez's Avatar
    josegamez Guest


    Did you find this post helpful? Yes | No

    Smile Thanks

    Ok I see your point, although those aren't quite equivalent yet. A verilog statement like Datum[6:4] = 2 would change all bits from bit 6 to bit 4 of Datum, turning Datum into X010XXXX where the X's are the previous bit values of Datum before the statement. So referring to Datum as Datum[6:4] is like having a new 3 bit variable where Datum[4] is the new bit 0, Datum[5] is the new bit 1 and Datum[6] is the new bit 2 to complete the three bit variable. But thanks I guess I'll have to work my way around with those sort of tricks. Thanks for your time, God bless.

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


    Did you find this post helpful? Yes | No

    Smile

    As is clear from above, I have never used verilog ...., for completeness this not so pretty approach still works

    Code:
    ;Datum[6:4] = 2
    Datum.6=0
    Datum.5=1
    Datum.4=0
    Code:
    ;IF PORTB[5:1] = 3 THEN
    If (PORTB & $3E) = $06 THEN
    OR you could blast the first type with inline ASM

    Code:
    ;Datum[6:4] = 2
    Datum var byte
    ASM
       movlw	0x20          ; b00100000 new values
       xorwf 	_Datum, W  
       andlw 	0x70          ; b01110000 mask values
       xorwf 	_Datum, F     ; bX010XXXX
    ENDASM
    Others might have a cleaner method?

    EDIT - added comments to ASM routine
    Last edited by paul borgmeier; - 2nd November 2006 at 20:41.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    josegamez's Avatar
    josegamez Guest


    Did you find this post helpful? Yes | No

    Thumbs up Ok

    OK thanks a lot, I'll try that

Similar Threads

  1. Easy and Accurate Clocks without RTC IC
    By paul borgmeier in forum Code Examples
    Replies: 18
    Last Post: - 28th October 2013, 21:28
  2. Transceiver ER900TRS Easy Radio
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th August 2008, 11:25
  3. Super easy 18F print strings to UART
    By Bruce in forum Code Examples
    Replies: 0
    Last Post: - 26th August 2007, 23:19
  4. EEPROM life expectancy?
    By muddy0409 in forum General
    Replies: 3
    Last Post: - 1st May 2007, 12:44
  5. Easy LCD BackLight
    By Melanie in forum Schematics
    Replies: 0
    Last Post: - 17th October 2004, 13:18

Members who have read this thread : 1

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