Serout2 and Interrupts 16F88


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1

    Default Serout2 and Interrupts 16F88

    I have a routine running in the background generating a 2khz pwm using TMR0.

    I want to use Serout2 to send out some data but the interrutps corrupt the flow of data going out on Serout2.

    To make it work I am having to disable the interrupt driven pwm, send the data then restart the pwm as in the below.

    Code:
    TMR0IE = 0                'Disable TMR0 interrupt enable bit (0 = Disabled)    
    serout2 AssistLed,16390,["DATA,TIME,",#Volts,",",AmpSign,",",#Amps,",",#Soc,",",#TempAvg,13]    'Sends logging data at 38400 baud
    TMR0IE = 1                'Enable TMR0 interrupt enable bit (1 = enabled)
    The problem is now the stopping of the 2khz pwm is causing problems in the associated hardware, it is noticing the missing pulses. To minimise that i have reduced the data I'm sending to the bare minimum, but the gap in pwm is still slightly noticeable. What I wanted to do is move the data I need to send into an array and then send one byte at a time which would allow the pwm to continue virtually unaffected as the many small gaps would be absorbed rather than the one big gap in the pwm stream i have now. Any ideas on how to get the formatted data from my Serout2 into an array or some other RAM location.

    I can't use HPWM that is already in use driving an LCD.

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


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    You have a 16F88.
    Use the USART with HSEROUT to send serial data.
    It will not be affected by interrupts.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Already in use driving LCD sorry forgot to mention that. I need to break up the data into single bytes to send via Serout2 somehow.

    I meant HSEROUT in my first post not HPWM of course Duh!! <roll>
    Last edited by retepsnikrep; - 25th August 2011 at 15:40.

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


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Can't you move the LCD pins?
    DT

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Serout2 and Interrupts 16F88

    Well, there's still the Synchronous method, but you need another I/o and must modify the receiver... maybe not a that good idea
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  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

    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

Members who have read this thread : 1

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