pic18f252 hserout problem


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

    Default pic18f252 hserout problem

    Ciao everybody.

    I try to migrate from pic16f876 to pic18f252. The software witch run on 16f876 is fully working, but when I transfer to 18f252 dont works.
    I try to expalin more bette the situation. My programm are witing a number with an interrupt from PC, if receive the right code then read some data from EEPROM and sent it to PC with HSEROUT.
    It works without limit on 16f876. I can read thousent numbers.
    On 18f252 works only for 26times, after this nothing!?!

    I need some help, please.

    PS. Sorry about my english.

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

    Default

    Post a sample of your code that doesn't work on the 18F part.
    Regards,

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

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

    Default

    This is a part of my code.
    As I write first my code works for 26 times only. This limit are only with 18f252, (not with 16f876).

    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

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

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

    Can be a problem of a buffer?
    Thanks again.

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

    Default

    mem_addr=mem_addr+16
    GoTo dummy '<--- this will be a problem
    EndIF
    ...
    Wend
    Resume
    Enable < -- do not GOTO outside of this block
    Be sure you have DISABLE before your interrupt service routine, and ENABLE
    after your interrupt service routine, and you stay within this block until you're
    finished with the interrupt service.

    Do NOT jump or GOTO outside the DISABLE ENABLE block. If you do, you have
    problems with the stack, and you're landing in a code section that will loop
    right back to the start of your interrupt service routine.

    You may get away with this on a 16F part since it will re-cycle back to the
    beginning of the stack. On the 18F part, it stops at the last location, and you
    cannot push another address onto the stack.
    Regards,

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

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

    Default

    With the first test, looks to be ok. Now it works.

    Thanks.
    edysan, Italy

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. Problem with ASM IRQ using FSR0 on PIC18F252
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th March 2008, 20:48
  4. HSEROUT Problem
    By Keith in forum General
    Replies: 2
    Last Post: - 25th June 2005, 15:09
  5. Advantages of HSerout over Serout2 and a problem
    By rpstroj in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th August 2004, 22:19

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