18LF4680 HSERIN and SEROUT hang my PIC!


Closed Thread
Results 1 to 3 of 3
  1. #1
    temp19's Avatar
    temp19 Guest

    Default 18LF4680 HSERIN and SEROUT hang my PIC!

    The program are simply. To receive serially @ 115.2kbps data, and sometimes send serially (not hardware) data out.
    initialization of hserin works well!

    INCLUDE "bs2defs.bas"
    DEFINE OSC 20
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_CLOERR 1
    DEFINE HSER_BAUD 115200

    start:

    hserin 100, start, [c, a, b]
    rcsta.4 = 0 : rcsta.4 = 1

    if c = "d" and a = "+" then sound portb.4, [119,7]
    if c = "e" and a = ":" then hpwm 1, b, 400
    if c = "s" then serout portc.4, t9600, [255, 8, 100]
    goto start
    ------------------------------------------
    everything work good and fine until c="s" and pic needs to transmit three bytes out of portc.4.
    PIC just hangs up until reset

    is something special about portC.4? am i missed something important?
    18LF4680 hardware TR RX are C6 and C7

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


    Did you find this post helpful? Yes | No

    Default Re: 18LF4680 HSERIN and SEROUT hang my PIC!

    smells of DMX project again

    DEFINE HSER_CLOERR 1
    that one do absolutely nothing, the spelling is wrong

    try these defines

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 10  ' 115200 Baud @ 20MHz, -1.36%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    If it's really DMX, you really need to study the protocol first, HSERIN will be of next to none use for that. There's a nice DMX paper on microchip website. I know I already posted it somewhere in here.

    Another thing, you may want to use a BaudrateVouched crystal for this baudrate. 1.36% err is not bad though.
    Last edited by mister_e; - 18th May 2011 at 22:59.
    Steve

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

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: 18LF4680 HSERIN and SEROUT hang my PIC!

    Hi temp19,
    2 things come to mind . . .
    #1 I would set sspcon1.5 = 0 to disable spi and make an I/O. It may default to this on POR but I did not see it in the data sheet.
    #2. Now I might be the only one who EVER had this trouble, but when making statements like :
    if c = "d" and a = "+" then sound portb.4, [119,7]
    it never works FOR ME without some brackets, like so
    IF (c = "d") AND (a = "+") THEN sound portb.4, [119,7]
    as I said it MAY work for everyone else, but not for me.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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