Problem with HSEROUT/HSERIN


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Problem with HSEROUT/HSERIN

    I have this code:
    Code:
    Gain:
    	HSERIN [STR Name\25\"*"] : Pause 250
    	HSEROUT [STR Name,"*"]
    for pass=0 to 24
    	Name[pass]=0
    next pass
    Goto Gain
    First time when program starts. I can see on serial communicator when data 'Home*' is received. Nothing comes as output

    I send it again 'Home*' it outputs 0

    Third time I send 'Home*' it outputs 'Home*'

    THEN I send 'abcd*' it outputs 'Home*'

    I send it again 'abcd*' it outputs 'abcd*'

    Similarly every different data after this comes to the output after sending it twice.

    Why is this happening?
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: Problem with HSEROUT/HSERIN

    Hi,
    Have you declared Name as an array of 25 bytes?
    Code:
    Name VAR BYTE[25]
    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Problem with HSEROUT/HSERIN

    Yes. Variables are able to hold the value.
    ___________________
    WHY things get boring when they work just fine?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: Problem with HSEROUT/HSERIN

    Hi,
    Then I don't know...
    That can't be all of the code can it? Try to reduce the code to the bare minimum which still shows the issue, then post that code.

    I've tried the following on a 18F25K20 running at 64MHz
    Code:
    DEFINE OSC 64
    DEFINE LOADER_USED 1            ' We're using a bootloader.
    DEFINE HSER_RCSTA 90h           ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h           ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1           ' Clear overflow automatically
    DEFINE HSER_SPBRG 138           ' 115200 Baud @ 64MHz, -0,08%
    
    SPBRGH = 0
    BAUDCON.3 = 1                   ' Enable 16 bit baudrate generator
    
    Name VAR BYTE[25]
    pass var byte
    
    Pause 200
    
    HSEROUT["Program start.",13]
    
    Gain:
    	HSERIN [STR Name\25\"*"] : Pause 250
    	HSEROUT [STR Name,"*"]
    for pass=0 to 24
    	Name[pass]=0
    next pass
    
    Goto Gain
    It seems to work fine using the serial communicator terminal built into MicroCodeStudio...


    /Henrik.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Problem with HSEROUT/HSERIN

    Here is the code, the problem is there:
    Code:
    '-----------------Defines & Includes----------------
    Include "modedefs.bas"
    DEFINE	OSC	20
    
    '------------------------Configuration Fuses-------------
    #CONFIG
        ifdef PM_USED
            device  pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
        else	
    		__CONFIG _HS_OSC & _WDT_OFF & _LVP_OFF & _CPD_ON & _CP_ALL & _PWRTE_ON & _BODEN_ON
       endif
    #ENDCONFIG
    
    
    @ ERRORLEVEL -306			' SUPRESS PAGE BOUNDRY ERROR
    
    '===================================
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 64  ' 19200 Baud @ 20MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    '======================================
    '--------------------REGISTERS-------------------------------
    PAUSE 100
    ADCON1=7						' No Analog
    CMCON=7						
    OPTION_REG=128
    TRISA=0 : PORTA=0
    TRISB=0 : PORTB=0	' Enter Button Input
    TRISC=%10000000 : PORTC=0  ' One pin to get data
    TRISD=%10000000 : PORTD=0
    TRISE=0 : PORTE=0
    CCP1CON=0
    
    Name Var Byte[25]
    Pass 	Var Byte
    '--------------------------------------------------------------
    
    Name=0 : Pass=0
    
    Gain:
    	HSERIN [STR Name\25\"*"] : Pause 250
    	HSEROUT [STR Name,"*"]
    For pass=0 to 24
    	Name[pass]=0
    next pass
    Goto Gain
    ___________________
    WHY things get boring when they work just fine?

  6. #6
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Problem with HSEROUT/HSERIN

    I have found im having the same problem, but I think Ive found a fix, you can tinker with it more. the program does not like the reset to 0 loop, also the name VAR make it 1 more than what you want so make it a 26, also put the loop first before doing serin/out and maybe add a pause 100 inside the loop. Im going to post my code for 8 bytes, its working great so far, i removed the loop and set each one seperately, it helped get rid of bad serial character loss/corruption dont know why though.

    Code:
    include "LCD_D.BAS"
    Define OSC 20	'USE ECIO, NOT ECPIO
    define HSER_BAUD 2400
    DEFINE HSER_BITS 8
    DEFINE HSER_CLROERR 1
    RCSTA = $90
    TXSTA = $20		'DO NOT USE $24
    TRISC = %10000000
    TRISD = 0
    
    Name Var Byte[8]
    
    Gain:
    Name[0] = 0
    Name[1] = 0
    Name[2] = 0
    Name[3] = 0
    Name[4] = 0
    Name[5] = 0
    Name[6] = 0
    Name[7] = 0
    Name[8] = 0
    HSERIN 5000,test,[STR Name\8] : Pause 250
    HSEROUT [STR Name, 13, 10]
    LCDOUT $FE, 2
    LCDOUT $FE, $80
    LCDOUT Name[0],Name[1],Name[2],Name[3],Name[4],Name[5],Name[6],Name[7]
    pause 250
    Goto Gain
    
    test:
    pause 100
    goto gain
    Hope this helps or gives ideas!
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

Similar Threads

  1. need help hserin/hserout cmucam4
    By siyete in forum Serial
    Replies: 3
    Last Post: - 17th December 2012, 22:49
  2. HSERIN and HSEROUT commands
    By ryan in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 6th January 2007, 22:11
  3. HSERIN and HSEROUT problems
    By amindzo in forum General
    Replies: 2
    Last Post: - 31st August 2006, 06:51
  4. Strange problem with the HSEROUT and HSERIN
    By PJALM in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th January 2006, 16:37
  5. Hserin/hserout ?
    By Scott in forum General
    Replies: 6
    Last Post: - 27th April 2005, 23:46

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