Need help multiplexing EUSART output


Closed Thread
Results 1 to 35 of 35

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Do you have any timers available?
    <br>
    I'm using 2 timers, and have 2 free.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    Timer1 maybe?

    I've been playing with this all day, just got it working a little bit ago.

    I don't know if this fits in with your program but I figured, Since the problem is the timing disruption of the SEROUT commands by the interrupts, that a SEROUT equivalent driven by a Timer might solve it. Kind of cross between USART and software serial. Might solve a lot of peoples SEROUT problems.

    Still have some more to do on it, but was wondering what kind of data you're sending. DEC, HEX, STR, ??

    Are your other Interrupt handlers SHORT?

    Which Timer is available?
    <br>
    DT

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Wow. Thats impressive.

    I'm sending strings of data. But of course that can be easily accomplished with sending bytes in a loop.

    The other interrupt handlers are mostly short. But i guess thats a relative term. Most of them just record an input, or an event and the time that it occurred, and throw that data in a circular buffer to be handled when the main program gets around to it .
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    Just strings?
    Are the strings in a RAM array.
    Or like HSEROUT ["Hello World"]

    Which Timer????
    <br>
    DT

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    RAM arrays.

    I'm using Timer0 and Timer1 at the moment, but i could prob use any for my application.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default Tmr_tx-18

    Kamikaze,

    I think this will do what you wanted, without any external OR/AND gates.
    There's so much more I could do with it.
    But it's already more than you need, so I think I'll stop now.

    This is an Include module, that sends Serial data using a Timer as the baud rate generator.
    Currently, it will only work on 18F's, and it's only the Transmit side.

    It can use any one of Timer 0, 1 or 3. But does not use interrupts.
    Outputs on any digital I/O Pin.
    Can send Bytes, Words, Strings from arrays, Strings from Flash and ASCII decimal values.
    Runs up to 115200 with 32mhz(or higher) OSC.
    You can use HSEROUT for the USART, and this as a second UART.


    Setup is pretty simple.
    Just tell it which Timer to use, the baud rate and the I/O Pin...
    Code:
    ;----[Setup Timer based UART]-------------------------------------------------
    DEFINE  TX_TIMER 1                 ; Timer used for serial UART (0,1 or 3)
    DEFINE  TX_BAUD  9600              ; Baud Rate
    TX_Pin  VAR PORTB.6                ; Output Pin
    INCLUDE "TMR_TX-18.bas"            ; Include the Timed Serial module
    The TX_Pin is automatically set to output and idles high. (assuming there's no A/D etc. enabled on the pin)
    Serial signal is 8N1 True. Same as the USART.

    If all you are sending is Strings from Array's, then you just need 1 Command...
    Code:
    @  TX_STR?B  _StrArray, _Length
    Which is functionally the same as,
    HSEROUT [STR StrArray\Length]
    where Length is a BYTE variable.

    A variation of the same thing uses a Constant Length (max 255)
    Code:
    @  TX_STR?C  _StrArray, 16
    Using just array's, the module will use about 250 bytes of program space.
    Using the additional commands may add up to another 200 byes plus string data.
    Relatively small, compared to HSEROUT.<hr>Additional commands that are available are...
    Code:
    @  TX?C       Const              ;- send a Char (constant 0-255)
    @  TX?B       _Value             ;- Send a byte from a BYTE var
    @  TX?W       _Value             ;- Send a binary Word var (LSB first)
    @  TX_DEC?B   _Value             ;- Ascii Decimal Byte, no leading 0's
    @  TX_DEC?W   _Value             ;- Ascii Decimal Word, no leading 0's
    @  TX_DEC?CB  Len, _Value        ;- Ascii Decimal BYTE, Len is a constant
    @  TX_DEC?CW  Len, _Value        ;- Ascii Decimal WORD, Len is a constant
    @  TX_STR?C   Str, Len           ;- Send an Array, Len is a constant
    @  TX_STR?B   Str, _Len          ;- Send an Array, Len is BYTE var
    @  LoadStr    _Array, Str, _Len  ;- Load an Array from flash, Returns
                                     ;  the length of the string in BYTE var
    @  TX_FSTR   Fstr                ;- Send Fixed String from Flash
    @  TX_DSTR   Dstr                ;- Send PreDefined String from Flash
    Examples...
    Code:
    @  TX?C  "A"                    ; same as HSEROUT ["A"]
    
    @  TX?B  _ByteVar               ; same as HSEROUT [ByteVar]
    
    @  TX?W _WordVar                ; HSEROUT [WordVar.LowByte, WordVar.HighByte]
    
    @  TX_DEC?B   _ByteVar          ; HSEROUT [DEC ByteVar]
    
    @  TX_DEC?W   _WordVar          ; HSEROUT [DEC WordVar]
    
    @  TX_DEC?CB  3, _ByteVar       ; HSEROUT [DEC3 ByteVar]
    
    @  TX_DEC?CW  4, _WordVar       ; HSEROUT [DEC4 WordVar]
    
    @  TX_STR?C   _StrArray, 13     ; HSEROUT [STR StrArray\13]
    
    @  TX_STR?B   _StrArray, _ByteVar  ; HSEROUT [STR StrArray\ByteVar]
    
    @  TX_FSTR   "Hello World\r\n"  ; HSEROUT ["Hello World",13,10]
    
    @  TX_DSTR   Wassup             ; no equivilent
    @Wassup  string "Hey dude, wasssssup!\r\n"
    
    @  LoadStr    _StrArray, "Put me in Array\r\n", _ByteVar  
                                    ; returns length of string in ByteVar  
                                    ; To send the array use ...
    @  TX_STR?B   _StrArray, _ByteVar
    It's probably a bit confusing, so let me know if it doesn't make sense.
    <br>
    Attached Files Attached Files
    DT

  7. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    All I can say is wow!

    Thats some nice work there Darrel.

    Thanks very much.

    I'll give it a go and report back
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

Similar Threads

  1. Help changing CCP3 output pin
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th July 2008, 03:30
  2. Bit Banging input to output on PIC16F876A
    By Bronurstomp in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th June 2008, 20:50
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 23:19
  5. HSEROUT Newbie question/problem
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th July 2006, 15:44

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