Serout2 and Interrupts 16F88


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    You might be able to play some 'tricks'. The LCD won't respond to anything on it's pins unless the ENABLE pin is low. Hopefully, you have HSEROUT connected to a DATA pin or the R/W pin.
    HSEROUT takes over a in when the port is enabled. Set SPEN high, Transmit your byte(s), wait one byte time for the last byte to be transmitted, and disable SPEN. Put a resistor between TXout and your MAX232. Connect an unused pin (call it the "blocking pin") to the junction of the resistor and the MAX232. Drive the pin high as soon as you get done transmitting the last byte, and tristate the pin before you send any data. Setting the blocking pin high will stop any garbage from going out on RS-232 while you write to the LCD.

    So, before you send a character using HSEROUT

    Tristate the blocking pin
    Enable SPEN
    Write the data
    Wait one byte time
    Set the blocking pin high
    Disable SPEN

    I haven't tried it, but it just may work.
    Charles Linquist

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Oh, and next time - ALWAYS use the hardware UART, and 18F parts!
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Quote Originally Posted by Charles Linquis View Post
    Tristate the blocking pin
    Enable SPEN
    Write the data
    Wait one byte time
    Set the blocking pin high
    Disable SPEN
    Oooooo, I... like it.
    Sort of.
    DT

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    I'm using a serial lcd at 9600 baud and if i move the lcd to another pin and drive it with a software serial routine that gets corrupted by the interrupt instead of the data out.

    If i can break the data I'm sending via the software serial routine down to byte size chunks the effect on my pwm is negligible. I can disable the interrupt for one byte at a time and use a subroutine to transmit it from some sort of ram buffer.

    I had thought of using the hserout for both devices by using a switch like a HCT4053 to change it from one to the other but my pcb won't allow that.

    I quite like that idea charles but when I'm transmitting data the lcd will display it as well which i don't want.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    I was thinking you were driving the LCD in 4 bit parallel mode. In your case, I would run my 16F88 at 20MHz and use DEBUGOUT at 57600 baud for one of the serial ports. DEBUGOUT has way lower overhead than SEROUT2. It takes less time to set up for the write and also allows you to run at
    higher baud rates than SEROUT2.
    Charles Linquist

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    And before I shut up tonight, with a little ASM, you wouldn't have to turn off interrupts at all.

    Just download and include one of the (fairly) easy to find RS-232 ASM routines. Run it at 57600 baud. Set up a one-byte buffer. Have the PWM ISR check for a "buffer full" flag. If set, it jumps to the RS-232 routine and sends the byte, and when that routine is done sending the byte, it clears the "buffer full" flag. Since your PWM ISR is running at 2Khz, you have 500uSec between interrupts. But you can send a byte (at 57600) in 180uSec. Plenty of time.


    Your main program loop could then just check the buffer full flag. If it wasn't set, it would write a byte the the buffer.

    No stopping interrupts, and no corrupted data.
    Charles Linquist

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Thanks for the ideas all. What is the max baud rate for debug? can it do 115200? It seems to compile ok i could not find a supported baud rate list.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Dave
    Always wear safety glasses while programming.

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