2k barrier variable problems


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2004
    Posts
    46

    Default 2k barrier variable problems

    I am working with a PIC16F876 using PBP. My program consists of about 6000+ words. I have declared all my variables at the start of the progam and used the CLEAR command also. After declaring a variable and setting it to a number (ie. X = 10) If I do a SEROUT2 command such as SEROUT2 TX, Baudrate, ["X= ", DEC X, 13, 10]

    I get the following response:
    X=


    However if I limit my program to 2000 words, I get
    X=10

    I cannot figure out what is causing this problem. Any help would be greatly appreciated.

    Kind Regards,
    Eric

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


    Did you find this post helpful? Yes | No

    Default

    Are you using some BRANCH or assembler interrupt ??

    Wich version of PBP are you using.

    Can you try place some variable into BANK 0

    MYVAR var byte BANK0
    Last edited by mister_e; - 19th December 2004 at 22:57.
    Steve

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

  3. #3
    Join Date
    Oct 2004
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Below is the code that is causing the grief. It is evidently not a 2k barrier problem but has to do with the SEROUT2 command. If I run the simple code shown below, the HyperTerminal shows:

    I:
    J:

    If I then get rid of the second SEROUT2 command, the Hyperterminal shows:

    I: 4
    I: 56

    It appears that the timeout, label of the second SEROUT2 command destroys the variable. Although I am not using the second SEROUT2 command, it's presense seems to effect the variables.

    I would be curious if you tried this yourself. It's either a bug or a possible problem with using PORTA pins of the 16F876.

    Kind Regards,
    Eric



    DEFINE OSC 20 ' define oscillator to be 20Mhz
    ADCON1 = 7 ' set the analog pins to digital

    ' serial connections
    RX VAR PORTA.3 ' receive (from PC)
    TX VAR PORTA.2 ' transmit (to PC)
    CTS VAR PORTA.1 ' clear to send
    RTS VAR PORTA.0 ' request to send

    ' General variables
    I VAR byte ' general variable
    J var byte
    BaudRate var word

    'Baud rate constants
    Baud96 CON 16468 ' 9.6K baud rate


    '1. set baud rate to 38400
    BaudRate = Baud96


    I = 4
    J = 56

    Main:
    pause 1000
    SEROUT2 TX, BaudRate,["I: ", DEC I, 13, 10,"J: ", DEC J, 13, 10]
    goto Main

    SEROUT2 TX\CTS, BaudRate, 200, NoData, ["Test"]
    NoData:
    Goto Main

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


    Did you find this post helpful? Yes | No

    Default

    Hi Eric,

    I got the same results here. Certainely not PORTA problem. I test it. Problem is the flow control... why not simply skip this and send it straight??? Can be safe to make some character pacing.

    I try different stuff to make it work... NADA. Trying only one SEROUT2 + flow control... Send only "I: " I miss certainely something here but...

    In all my apps, since the begining, i'd never use any kind of flow control. At this time, never had any problem with them too.

    Sorry !!!

    If you find something, let me know.

    Anybody got great results with flow control option with SEROUT2 here ???

    regards
    Steve

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

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I found the same problem. If I remove the timeout value and label in the SEROUT2 line with flow control it works.

    Code:
    DEFINE LOADER_USED 1
    DEFINE OSC 20   ' define oscillator to be 20Mhz
    ADCON1 = 7      ' set the analog pins to digital
    RX VAR PORTC.7  ' receive (from PC)
    TX VAR PORTC.6  ' transmit (to PC)
    CTS VAR PORTC.1 ' clear to send
    RTS VAR PORTA.0 ' request to send
    
    ' General variables
    I VAR byte
    J var byte
    K VAR BYTE
    L VAR BYTE
    M VAR BYTE
    N VAR BYTE
    I = 7
    J = 8
    K = 9
    L = 10
    M = 11
    N = 12
    
    Main:
        SEROUT2 TX, 84,["I: ", DEC I, 13, 10, "J: ", DEC J, 13, 10]
        SEROUT2 TX, 84,["K: ", DEC K, 13, 10, "L: ", DEC L, 13, 10]
        SEROUT2 TX, 84,["M: ", DEC M, 13, 10, "N: ", DEC N, 13, 10]
        pause 1000
        goto Main
    
    NoData:
        ' The line below does not work
        SEROUT2 TX\CTS, 84, 200, NoData, ["Test"]
        ' This one below works if above is commented out
        ' SEROUT2 TX\CTS, 84, ["Test"]
        Goto Main
    With the timeout and label options used in the NoData routine, the Main routine sends;
    I: 7
    J:
    K: 9
    L:
    M: 11
    N:

    Comment out the timeout & label line, un comment the lower, and it works sending this;

    I: 7
    J: 8
    K: 9
    L: 10
    M: 11
    N: 12

    Seems to always trash the 2nd variable with flow control and the timeout/label options used in NoData.

    I sent Jeff at MeLabs an email. He's looking into it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Oct 2004
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Hey, thanks for all your input. At least I know I am not crazy. I'll abandon flow control for the time being but would be very interested in what metlabs has to say.

    Regards,
    Eric

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Big thanks to Jeff at MeLabs for the super fast fix to this one.

    Here's the fix.

    Open your PBPPIC14.LIB file.

    Add the following 3 lines of assembler starting at line 5011 in PBPPIC14.LIB:
    Code:
         ifdef SEROUT2TO_USED
            bsf STATUS, C ; Set carry for no timeout in case of blanking
         endif
    When finished it should look like this from line 5010 to 5019;
    Code:
    serout2send1 movf R0, W         ; Get char back
        ifdef SEROUT2TO_USED
            bsf STATUS, C ; Set carry for no timeout in case of blanking
        endif
            btfss   STATUS, Z       ; If zero, goto blank check
            bcf     GOP, 7          ; Not zero so clear blank
            btfsc   GOP, 7          ; If blanking on, don't send
            return
            addlw   '0'             ; Add ASCII offset
            goto    JUMPMAN         ; Send it
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Great !

    Isn't this somthing that should go to the FAQ section?

    Subject: SERIN2 FlowControl / TimeOut . . .

    regards:

    Ralph

  9. #9
    Join Date
    Oct 2004
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Bruce,

    Thank you very much for the speed in solving this issue. I tried it out and it works great! I would thank Jeff personally but I don't know his email. Please pass on my thanks.

    Kind Regards,
    Eric

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. variable problems
    By DmitriK in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th June 2008, 21:19
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 21:16
  5. Problems with variable - Advise welcome
    By tracking in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th June 2005, 18:40

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