ascii conversion help needed


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    What you need is the Bitwise operators "&" + "|" (OR).

    Since you only want to output the lower bits of PORTB, you have to read PORTB first, mask out the lower bits, then OR the new bits in.

    portb = (portb & %11110000) | (var & %00001111)
    <br>
    DT

  2. #2
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,
    I've been up all nite trying to sort this thing out. Let's see if I can explain where I am ATM:

    I've got 5 bytes coming in as 5 hex2 numbers.
    I am taking the low nibble of each of those as hex1 numerals.
    Gotta then convert then to dec1 digits and write them to port b low nibble.
    I think I've got it sorted...

    I don't think I will need to read, mask, or, then write portb as there is a set sequence that needs following, but that will be another problem, probably.
    I just gotta write the low nibble with the high nibble all 0's and then do some bit manipulation with the high nibble. Should be pretty easy.

    Famous last words huh?

  3. #3
    Join Date
    Jul 2006
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Im not sure if this is what you need but, it is a simple Ascii to hex converter. This assumes the stringbyte is limited to valid hex characters.

    ConvertAscii_to_Hex:

    StringByte = StringByte - 48
    Lookup StringByte, ( 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,10,11,12,13,14,15) , Returnbyte

    Return

  4. #4
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Rightyo, thanks for all the help blokes. I got it all sorted out.
    It may not be pretty, but it works a treat.

    And it fits in the codespace.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

Similar Threads

  1. ASCII to Long conversion
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th March 2009, 23:43
  2. A/D conversion problem in 18F2520, 2523, 2550 etc.
    By selimkara in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 10th March 2008, 16:26
  3. SerIn2 ASCII Conversion
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 4th March 2008, 21:41
  4. ASCII Viewer Needed
    By sougata in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th January 2008, 05:29
  5. Conversion of 10-bit word into ASCII
    By Barry Johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th January 2005, 14:26

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