serial data ideas please


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    Hi,
    Normally you need to enable the PLL by setting the correct CONFIG (which you now have set to INTIO67) but it seems as if, when using the internal oscillator, you enable it by setting PLLEN bit (OSCTUNE.6) - which apparently have done... So, right now I can't think of anything in particular but I'd take an extra read thru the Oscillator section of the datasheet and take a look if there indeed IS a CONFIG which seems reasonable for internal oscillator WITH PLL.

    /Henrik.

  2. #2
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    The one thing I can see would help is not to do the transmission inside the interrupt loop. Not sure how PBP implements the HSEROUT (you'll need to look at the ASM list for that), but most compilers will check the buffer empty condition, load the USART, and (many times) wait until the buffers empty again before exiting the routine.

    The USART normally consists of two registers: TXREG and TSR. You load the TXREG with the information you want to send, if the TSR is empty then the TXREG is loaded into the TSR on the next Tcy; this is not an issue. But if the TSR is full (or currently sending data) then you must wait until it empties before the TXREG can load it and create the Buffer Empty condition. Because the USART is a serial device, you could potentially need to wait for 8-bits to be serially sent, before the TXREG is emptied. This could cause a bottleneck on the transactions.

    In your case, since you are receiving and sending at 9600bps on one side, and receiving at 10400bps on another; you could potentially hold the 10400bps, while waiting for the TXREG to clear. To work around this, you can load the TXREG directly (if it's empty), and if not, wait for the next go-around until it empties. That way you eliminate the potential of holding the 10400bps reception waiting for the 9600bps transmission. Hopefully this is a bit more clear.

    Some Pseudo code:

    Code:
    Main_Loop:
        PIE1.RCIE = FALSE '(disable EUSART Receive Interrupt Enable bit)
        IF PIR1.TXIF = TRUE THEN '(if TX buffer empty)
            nextout = nextout % buffer_size
            HSEROUT buffer[nextout]   
            nextout = nextout + 1
        ENDIF
        SERIN.... (perform SERIN routine, with timeout - this is important)
        PIE1.RCIE = TRUE '(enable EUSART Receive Interrupt Enable bit)
        GOTO Main_Loop
    Code:
    Interrupt Service:
        nextin = nextin % buffer_size
        HSERIN buffer[nextin]   
        nextin = nextin + 1

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    Thanks for that idea. I'll try it

    I'm still concerned that the pic is not running at 32mhz yet? My config must be wrong somewhere :?

  4. #4
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    I run an 18F2620 at 32MHZ with the internal OSC. Here is my config.

    Code:
    OSCCON=(percent)01110000               ' SET TO 8 MHZ internal oscillator
    OSCTUNE=(percent)11000000              ' TURN ON PLL X4 FREQ NOW 32MHZ
    replace (percent) with %
    Shawn

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    Shawn

    Can you post this part of you config as well please?

    Code:
    #CONFIG
     __CONFIG _CONFIG1H, _OSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
     __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOREN_OFF_2L
     __CONFIG _CONFIG2H, _WDT_OFF_2H
     __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
     __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    #ENDCONFIG

  6. #6
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    Sorry, I don't put my configs in the code like that. I set them with PICFLASH when I program my pics. What you have looks correct to me though.
    Shawn

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: serial data ideas please

    Pic now seems to be running at 32mhz and able to keep up, so problem may be solved. Thanks for the ideas.

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