hserout and serial 7 segment display


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    It doesn't say if it should be inverted or true mode.
    I did try [hex bright,0] and other permutations, like sending the Ascii value "z" instead.

    I finally put a scope on it and tried to relate the command to the scope trace. This is what I got for $7A (brightness control, Ascii "z")

    Name:  Reversed7A.gif
Views: 1457
Size:  7.3 KB

    When I write the binary version out, it is indeed $7A or %0111 1010, except it's back to front. What I would have expected to be the msb at the front end of the trace, is at the back end. In other words, what is being sent is not $7A, but %0101 1110. (At least when I used to demonstrate RS-232 signals, they used to follow that convention). Tell me if I'm wrong.

    So, what do you guys figure is happening? Maybe the inverted/true mode business? How do I choose either mode? I was looking at the REV command to reverse all the bits, but that seems rather "kludgy".

    The latest code:

    Code:
    DEFINE OSC 4                                                                                      
    DEFINE HSER_RCSTA 80h ' Enable serial port (b7=1 to enable TX as serial port pins
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    define HSER_BAUD 9600                   
    'DEFINE HSER_SPBRG 25  ' 9600 Baud @ 4MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    trisc.6=0
    LED var portc.6   
    '****The following are the control codes for the Sparkfun serial 7-segment display
    decpts con $77   ' "w"
    bright con $7A   ' "z"
    setbaud con $7F '2=9600, 4=19200
    reset   con $76  ' "v"
    lsb     con $7B  ' "{"
    dig2    con $7C  ' "|"
    dig3    con $7D  ' "}"
    msb     con $7E  ' "~"
    
    
    'hserout [setbaud,2]
    Main:  
    HSEROUT [bright, $ff]
           pause 50
    goto main

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    I don't know where you ever thought that IEEE RS232 sent msb... They have been designing hardware USARTS with lsb for about 40+ years. You should Google RS232 protocol.... It's the LAW.....
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    You're right, I'm an idiot. Of course it's lsb first. For some STUPID reason I was thinking the first bit was a STOP bit, not a START bit and got the whole thing wonky. It's been awhile since I've had to troubleshoot serial stuff.

    Okay, now I've got it and it's even more perplexing that this doesn't work since the display is getting the right code. When I send out [$7A, $55], that's indeed what I see on the scope.

    I think it's a timing issue and tried using DEFINE CHARACTER_PACING but that doesn't work either for values 1000 to 20000.

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    Silly question, but have you tied the unused inputs appropriately? You may be getting noise resetting things or sending garbage on the SPI port...

  5. #5
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    Unused inputs? You mean Rx? Are there more? The 16F887 is in the LabX1, all jumpers are in except the Tx, which I am using as an output.

  6. #6
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: hserout and serial 7 segment display

    I figured what Charlie meant was unused SPI inputs on the display (which can use SPI or serial in). I tied the 3 inputs to ground, no change, then out of frustration (I had already thrown the display in the garbage...)I started hitting each pin with ground. After touching the RST (which I assume is reset), the display started working. No changes in code, and when I took off extraneous wires to the display (ie the 3 SPI inputs) and hooked it up in very basic mode with only SI, Vcc, and ground, it continued to work, even through power cycling and numerous downloads to the host chip (16F887). I can now display anything I want, anywhere I want.

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts