HSEROUT problem


Closed Thread
Results 1 to 16 of 16

Thread: HSEROUT problem

  1. #1

    Default HSEROUT problem

    I am trying to operate my solenoid to lock/unlock VIA SMS, but i have errors like

    ERROR: Macro HSEROUT2?T not found in macro file.
    ERROR: Macro HSEROUT2?C not found in macro file.
    ERROR: Macro HSEROUT2COUNT?C not found in macro file.
    ERROR: Macro HSEROUT2NUM?B not found in macro file.
    ERROR: Macro HSEROUT2DEC? not found in macro file.

    i read quite afew forums on HSEROUT problems but none address to such.
    is there any solutions to such errors??

    thx

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251

    Default

    Please post your complete code in a code window here, then we can see what you forgot in your code.

  3. #3

    Default THX Mat

    here is my code as my board could not read serin and serout, i have no choice but to use other alternative like hserout.


    '************************************************* ******************************
    ' Hardware Defines *
    '************************************************* ******************************
    'PIC16F876A specific
    ;__config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF


    DEFINE LOADER_USED 1
    DEFINE OSC 20

    DEFINE HSER_BAUD 9600
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 129
    DEFINE HSER_CLROERR 1

    '************************************************* ******************************
    ' Define program variables *
    '************************************************* ******************************
    NumLen var byte ' Tel Number length
    PhoneNo var byte[16]' Phone Number string
    SPhoneNo var byte[16]' Phone number in SMS
    Index var byte ' Index of the SMS
    Cmd var byte[7] ' The command
    X var byte ' Temp Var
    MsgType var byte
    position var byte



    '************************************************* ******************************
    ' Inputs / Outputs & Port Assignments *
    '************************************************* ******************************
    Tx var PORTB.6 ' Tx Rs232 to Terminal
    Rx var PORTB.7 ' Rx Rs232 from Terminal

    '************************************************* ******************************
    ' Set TRIS and system REGISTERS *
    '************************************************* ******************************

    TRISB=%11111111 ' Port B input
    TRISC=%00000000 ' Port C output


    'Message to be send: LOCK and UNLOCK

    InitModem:
    pause 1000
    gosub init

    pause 1000

    Begin:
    MsgType = 0

    LOOP:
    PORTC.7 = 0
    GOSUB ChkSMS
    GoSUB Read_input

    PAUSE 10000
    IF MsgType=0 then
    GOTO LOOP
    endif
    END

    '************************************************* ******************************
    ' Subroutines *
    '************************************************* ******************************

    '************************************************* ******************************
    ' SMS Subroutines
    '************************************************* ******************************
    Init:
    ' Subroutine to initialise the module

    HSerout2 [Tx,84,"AT",13] ' CLIP command
    SERIN2 Rx,84,5000, Problem,[Wait ("OK",13)] ' Loopback to NotReady
    HSerout2 [Tx,84,"AT+CLIP=1",13] ' CLIP command
    Pause 500
    HSerout2 [Tx,84,"AT+CNMI=3,0",13] ' SMS now not polled
    Pause 500
    HSerout2 [Tx,84,"AT+CMGF=1",13] ' Set Text Mode
    Pause 500
    'Preferred Message Storage: ME on Phone
    HSerout2 [Tx,84,"AT+CPMS=",34,"ME",34,13] ' Changed for GR47
    Pause 4000
    'Set the storage to SIM
    HSerout2 [Tx,84,"AT+CPBS=",34,"SM",34,13] ' Otherwise cannot read memory loc1
    SERIN2 Rx,84,5000, Problem,[Wait ("OK",13)] ' Loopback to NotReady
    'Select Character Set “UTF-8” : Universal text format, 8 bits
    HSerout2 [Tx,84,"AT+CSCS=",34,"UTF-8",34,13] ' for @ sign problem
    pause 1000
    HSerout2 [Tx,84,"AT&W",13] 'Store User Profile to non volatile memory
    pause 1000
    'HSerout2 Tx,84,"AT+CMGD=1,4",13
    'pause 1000

    Return


    ChkSMS:
    HSEROUT2 [Tx,84,"AT+CMGL=",34,"ALL",34,13]
    SERIN2 Rx,84,2500,OutSMS,[Wait("MG")]
    gosub rdsms

    OutSMS: 'no sms received
    return

    RdSMS:
    ' at+cmgl="ALL"
    ' +CMGL: 1,"REC UNREAD","+60123288328","PEC 9720 A","03/05/09,12:10:59+32",145,5
    ' Test1
    ' +CMGL: 2,"REC UNREAD","+60123288328","PEC 9720 A","03/05/09,12:13:27+32",145,5
    ' Test2
    '
    ' OK

    SERIN2 Rx,84,1500,KL_SMS,[Wait(":"),Skip 1,DEC Index]
    SERIN2 Rx,84,1500,KL_SMS,[Wait(34),Wait(","),Skip 2,STR PhoneNo\12,Wait(10),STR Cmd\4]
    SERIN2 Rx,84,4000,WAITOK,[Wait("OK")]

    gosub chknumlen ' check number length again

    pause 10000
    Gosub SendMsg

    KL_SMS:
    ' If I got an SMS I have to Kill it now

    IF Index=0 Then return
    pause 5000
    HSerout2 [Tx,84,"AT+CMGD=",DEC Index,13]
    index=0
    pause 1000
    RETURN

    '************************************************* ******************************
    ChkNumLen:
    ' Here I check the Length of Phone Number String
    ' Now determine the PhoneNo string length by looking for the inv commas

    For x=1 to 15
    IF PhoneNo[x]=34 Then
    NumLen=x
    return
    Endif
    Next x
    NumLen=16 ' cant Find so must be 16
    if PhoneNo[0]=34 then Numlen=0 ' we look for ""
    return

    '************************************************* ******************************
    SendMsg:

    GoSub ChkMsgType

    Select case MsgType
    case 1:
    GOSUB LOCK
    CASE 2:
    GOSUB UNLOCK
    end select
    pause 10000
    MsgType=0
    'HSEROUT2 Tx,84,["AT+CMGS=",34,STR PhoneNo\NumLen, 34,13]
    'HSERIN2 Rx,84,4000,Problem, [Wait(">")]
    'Select case 1
    ' case 1:
    ' HSEROUT2 Tx,84,["Message received OK", $1a]
    ' CASE 2:
    ' HSEROUT2 Tx,84,["Message received Fail", $1a]
    'end select
    RETURN

    '************************************************* *****************************
    ChkMsgType:
    IF Cmd[0]="L" && Cmd[1]="O" && Cmd[2]="C" && Cmd[3]="K" Then
    MsgType = 1
    RETURN
    ENDIF
    IF Cmd[0]="U" && Cmd[1]="N" && Cmd[2]="L" && Cmd[3]="O" && Cmd[4]="C" && Cmd[5]="K" Then
    MsgType = 2
    RETURN
    ENDIF
    MsgType=0
    return

    '************************************************* *****************************

    LOCK:

    PORTC.7 = 1
    pause 5000
    RETURN

    UNLOCK:

    PORTC.7 = 0
    pause 5000
    RETURN

    ''*************** Manual control of servo using push-buttons*******************

    Read_input:

    if PORTB.7 = 0 then
    PORTC.6 = 0
    endif

    if PORTB.7 = 1 then
    PORTC.6 = 1
    endif

    pause 50
    goto Read_input

    '************************************************* *****************************
    BKERROR:
    GOTo BKERROR
    WAITOK:
    GOTo WAITOK

    '************************************************* ******************************
    Problem:
    Pause 1000
    GOTO Problem

  4. #4

    Default

    thx for the post, but constructive help please
    seriously important.

  5. #5
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251

    Default

    First of all The used chip has only 1 hardware uart so HSERIN and HSEROUT without the 2 behind is normaly used.
    Then you combine behind the HSEROUT the modifiers of the SEROUT command.
    I can tell you ofcource what you had to type, but you will learn more by yourself if you read the exact used modifiers used for the HSEROUT (HSERIN) command and the SEROUT (SERIN) command and what is the difference beteween those two commands.
    You can find it in the book that came with the compiler or you can download it by www.melabs.com

  6. #6

    Default

    hey mat,
    thx for the help but i still dun quite get it.
    meaning that my HSEROUT is code wrongly??
    am i missing something??

    i meant i dun quite get this part
    "without the 2 behind is normaly used.
    Then you combine behind the HSEROUT the modifiers of the SEROUT command."

  7. #7
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251

    Default

    Indeed.
    Look into the documents and you see:
    HSEROUT [Item{,item....}] as HSEROUT [data1] when more HSEROUT [data1, data2, data3]

    SERIN Pin,Mode,{Timeout,Label,}{[Qual...],}{Item...}

    The Hser... commands are already defined by the statements:
    DEFINE HSER_BAUD 9600
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 129
    DEFINE HSER_CLROERR 1

    I hope you understand what I meant to say.
    In your programm you made a mix of the the both.

  8. #8

    Default

    hey mat,
    thx for all the help.

    so how should i go about changing the codes??
    basically i nv use HSEROUT before,
    so i dun really understand it.

  9. #9
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Williamaybe View Post
    so how should i go about changing the codes??
    basically i nv use HSEROUT before,
    so i dun really understand it.
    There's no reason why you can't use SEROUT in place of HSEROUT, just configure the I/O as general purpose rather than a serial port.
    And you're trying to user HSEROUT2. If you read your PBP manual, you'll see that HSEROUT2 is reserved for PICs with 2 hardware serial port modules, something that the 16F876A does NOT have.

  10. #10

    Default

    thx ski for telling me that.
    but seriously i dunno why.
    when i write serout and serin,
    my programme doesnt really function as expected.

    "my modem does receive the message that i send
    but somehow there is no output"

    is there any problems with it??

  11. #11
    skimask's Avatar
    skimask Guest

    Default

    Like Mat said earlier, your usage of the HSEROUT command is almost totally incorrect. RTFM applies in this case...or even look at the command structure in the manual, or Mat's post earlier.

  12. #12

    Default

    hey ski and mat,
    thx for all ur help.
    but i guess im kinda slow in getting it.

    wats RTFM supposed to mean??
    i dun quite get it

    still i gt 1 small problem.
    is there difference between a receiving and transmitting code??

    cuz recently i wrote a transmitting code,
    its able to send sms, but when i save the same thing for receiving. it doesnt work.

    and lastly,
    wat does
    "Define ONINT_USED 1 'Serves as LOADER_USED for versions before 2.33 "
    supposed to mean.

  13. #13
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Williamaybe View Post
    hey ski and mat,
    thx for all ur help.
    but i guess im kinda slow in getting it.
    wats RTFM supposed to mean??
    i dun quite get it
    still i gt 1 small problem.
    is there difference between a receiving and transmitting code??
    cuz recently i wrote a transmitting code,
    its able to send sms, but when i save the same thing for receiving. it doesnt work.
    and lastly,
    wat does
    "Define ONINT_USED 1 'Serves as LOADER_USED for versions before 2.33 "
    supposed to mean.
    RTFM = Read The F...... Manual
    Is there a difference between receiving and transmitting code?
    Is there a difference between talking and listening?

    Which version of PBP are you running?

  14. #14

    Default

    the serious part is,
    i dun haf a manual.
    thats why im tryin to figure my way out.
    i duno anythin abt writing programme.

    PBP??
    im using microcode studio to write my program.

  15. #15
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Williamaybe View Post
    the serious part is,
    i dun haf a manual.
    thats why im tryin to figure my way out.
    i duno anythin abt writing programme.

    PBP??
    im using microcode studio to write my program.
    Microcode Studio is a Suite, a front end for other programs, nothing more than a fancy editor (albiet a FANCY editor that handles a lot of stuff for you).
    PBP is the compiler, MPLAB/MPASM (or PM) is the assembler, and you have your choice of a bunch of programmers.

    So, which version of MCS, PBP, MPLAB/MPASM are you using?
    Which programmer?

  16. #16

    Default

    hey ski,
    im using PicBasic Pro
    but i duno wat version.

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. 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