Serial help


Closed Thread
Results 1 to 4 of 4

Thread: Serial help

  1. #1
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159

    Default Serial help

    I have acquired one of THESE for a project. I was out of I/O lines, and need a 4-digit display. This seemed like a great idea, since I only need the SEROUT2 command and one pin (I'm using the hardware TX and RX for comms to another device).

    The datasheet shows the following commands:

    Example: Display 12Ab
    To display 12Ab, any of the following 4-byte patterns would be acceptable:
    [0x01][0x02][0x0A][0x0B] (Actual binary values 1, 2, 10 and 11)
    [0x31][0x32][0x41][0x42] (ASCII-code for '1', '2', 'a', 'b')

    Or any combination of binary and ASCII values could be used.

    Sample Arduino Snippet (Serial mode):

    // ... after initializing Serial at the correct baud rate...
    Serial.write(0x01); // Hex value for 1, will display '1'
    Serial.write('2'); // ASCII value for '2', will display '2'
    Serial.write(0x0A); // Hex value for 10, will display 'A'
    Serial.write('B'); // ASCII value for 'B', will display 'b'


    It also mentions that CLEAR SCREEN is $76 (HEX 76).

    I have never used serial on a PIC before, so I know I'm doing something wrong. When I use the following command:

    Code:
    SEROUT2 PORTB.3,84,[HEX 76]
    Nothing happens. When I make a variable equal to HEX 76 and send that, still nothing, When I make two variables equal to 118 decimal ($76) and another variable equal to 7, I get '1187' in the display. I have tried IHEX as well, and still no joy. Anyone got any ideas what I'm doing wrong?

    Thanks for any help

    Andy
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Serial help

    Hi,
    Never used one of those and I don't quite understand what "nothing happens" actually means. Are you saying that you have data on the screen but when executing the Clear Screen command the screen does not clear?

    Anyway, the PBP equivalent of the following Arduino code
    Code:
    Serial.write(0x76);  // Clear display command, resets cursor
    Serial.write(0x01);  // Hex value for 1, will display '1'
    Serial.write('2');   // ASCII value for '2', will display '2'
    Serial.write(0x0A);  // Hex value for 10, will display 'A'
    Serial.write('B');   // ASCII value for 'B', will display 'b'
    would be something like:
    Code:
    SEROUT2 PortB.3, 84, [$76]  'Clear the display
    SEROUT2 PortB.3, 84, [$01, "2", $0A, "B"]   ' Display 12AB
    What if you try:
    Code:
    For i = 0 to 1000
    SEROUT2 PortB.3, 84, [$76, DEC4 i]
    PAUSE 1000
    NEXT
    /Henrik.

  3. #3
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Serial help

    Thanks Henrik. I looked over what I wrote, and I was tired at the time. Yes, what I meant was that clear screen did not work, but if I sent decimal numbers, they showed up in the display. I am at work and will try your suggestions tonight.

    Thanks
    Andy
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  4. #4
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Serial help

    Thank you so much Henrik. Your knowledge has once again saved me and I understand it now.

    Works great!
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

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