pic18f252 hserout some times is incomplete


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Default pic18f252 hserout some times is incomplete

    Ciao everybody.

    With your help I fix my last bug, and I am back again with a strange problem in the same code.

    Now the code it works fine, but some time HSEROUT is incomplete.

    This is the result of runing of my code:
    ...
    07335744556311114188340130000
    07335744556311114188340130000
    07335744556311114188340130000
    073357445563111107335744556311114188340130000 <- this is wrong
    07335744556311114188340130000
    07335744556311114188340130000
    07335744556311114188340130000
    ...

    Can you help me?

  2. #2
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237

    Post

    I've seen it when using Hyperterminal with a high baudrate, lots of data and a slow computer. It was ofcourse not the HSERIN that was to blame. Try a different terminalprogram. If this isn't your setup, i have no idea what's going on. I've never had any problems with HSEROUT. The only thing i can think of that possibly could be called a problem with HSEROUT is that you can loose data if you end the program right after a HSEROUT statement .....

    HSEROUT Blah,blah ...
    END

    The HSEROUT will not complete since the END will kill the OSC before the last character is sent. A PAUSE after HSEROUT will cure that problem.

    /Ingvar

  3. #3
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Default

    Thanks for answer.

    I use the same code with PIC16F876 and works fine.
    The problem is only on PIC18F525, and is verry random (never in the same point).
    I will tay to explain better what I wont to have from my code:
    A lot of numbers are saved on EEPROMs, when the acquisition are stoped I need to transfer this numbers on PC. I do this with Hserout. The Pic read the EEPROM and send this numbers to PC. I need to read, on my PC software, the same lengt of caracters, if the lenght of string are difrent I have a lot of errors, and missing data.
    This problem of incomplete string are present in all PC application (Hiperterminal, CodeDesigner/Debug, etc...).

    This is a part of my code.

    DEFINE OSC 20
    DEFINE HSER_CLROERR 1
    DEFINE HSER_BAUD 57600
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    ...
    INTCON = %11000000
    PIE1.5 = 1
    ...
    ON INTERRUPT GoTo loopdata
    ...
    loopdata:
    While RCIF
    B1=RCREG

    IF B1=48 Then HSerout ["Speed is ...",10,13] ' caracter ascii 48= "0"

    IF B1=49 Then ' caracter ascii 49= "1"
    For m=1 TO 16
    I2CRead sda_A,scl_A,ctl,mem_addr+(m-1),[data[m]]
    Next m

    HSerout [DEC2 data[1],DEC2 data[2],DEC2 data[3]...,10,13] <-this is the problem!?!

    mem_addr=mem_addr+16
    EndIF
    ...
    Wend
    Resume
    Enable
    ...
    dummy:
    For X = 0 TO 300
    PauseUs 200
    Next X
    GoTo dummy
    ...
    End

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

    Default

    You don't show it in your example, but do you have DISABLE before the
    loopdata interrupt sub-routine?
    Regards,

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

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

    Default

    Another thing you can't really tell from the partial program, is if the program can "Fall into" the interrupt handler without an interrupt. As shown, it would.

    That might cause stack underflow problems.

    .
    DT

  6. #6
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Default

    Ciao.

    Yes, I have DISABLE before the loopdata interrupt sub-routine.

    My code run for nothing in dummy:, when receive an character from PC run the interupt and read data from EEPROM end send it to PC with HSEROUT.
    I dont think can "Fall into" the interrupt handler without an interrupt.

    Some times (verry rare) my code works without problem, but most of times I have this random error.
    The same code with PIC16F876 works fine.

    Thanks.
    I wait any way other ideas.

Similar Threads

  1. I2C Slave with a PIC
    By ralfmayr in forum mel PIC BASIC Pro
    Replies: 129
    Last Post: - 21st August 2016, 17:44
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  3. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 16:26
  4. pic18f252 hserout problem
    By edysan in forum Serial
    Replies: 4
    Last Post: - 16th June 2006, 20:46
  5. Strange HSEROUT execution times
    By SteveB in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st May 2006, 18:34

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