debug not working with MPASM assempler


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2005
    Posts
    44

    Default debug not working with MPASM assempler

    i am trying to compile the below code with MPASM assempler but i receive garbage when i checking with hyper terminal the debug but when i change the assempler and compile it again it works fine.do you know why this happends?i want to use darrel interrups so i have to compile it with MPASM. i am using PBP 2.47 and microcode studio 3.0.0.5.

    '---------DEFINES---------------------------------
    define osc 12
    DEFINE DEBUG_REG PORTB 'set pin port for debug
    DEFINE DEBUG_BIT 5 'set pin bit for debug
    DEFINE DEBUG_BAUD 4800 'set debug baud rate for debug
    DEFINE DEBUG_MODE 0 'set debug mode 0=true

    '----------VARIABLES-------------------------
    temp1 var byte
    temp2 var byte
    dist var word
    command var byte
    temp3 var byte
    flag var byte 'this flag is for checking


    '----------SYMBOLS-------------------------
    SYMBOL led=portb.7
    symbol sensor_tx=portc.0
    symbol sensor_rx=portc.1
    symbol wireless_rx_tx=portc.3
    symbol wireless_tr_re=portc.2


    '---------INITIAL----------------------------
    INTCON=0 'no interrupts
    CMCON=7 'comparators off
    TRISC.4=0 'make trisc bit 4 output
    TRISC.3=0 'make trisc bit 3 output
    TRISC.0=0 'make tx sensor output
    TRISC.1=1 'make rx sensor input
    TRISB.7=0 'make trisb bit 7 output
    TRISC.2=0 'make trisc bit 2 output
    ADCON1=7 'turn off a/d module
    flag=0

    '-------------MAIN PROGRAMM-------------------------
    clear 'clear all variables in ram
    gosub logo 'print the logo on local debuger
    HIGH led 'light the led
    main:


    gosub sensor 'take the distance
    if dist=0 then
    goto error_sensor 'if no value the sensor not connected jump to error
    goto main 'loop to main
    endif
    wait_for:

    gosub wait_wireless 'wait to read the command from remote
    debug "the value is ",dec dist,10,13
    gosub send_data ' transmit data wireless
    GOTO wait_for
    end

    '------------END OF THE PROGRAMM---------------------------------------------




    '--------------LABELS-------------------------------------------

    sensor:
    temp1=0 'clear variable
    temp2=0 'clear variable
    dist=0 'clear variable
    if flag=0 then
    serout2 sensor_tx,84,[0,84] 'send serial command to sensor if not jump to error_sensor
    serin2 sensor_rx,84,500,error_sensor,[temp2,temp1] 'receive the value if don't jump to error_sensor
    else
    serout2 sensor_tx,84,[0,84]
    serin2 sensor_rx,84,500,error_sensor2,[temp2,temp1]
    endif
    dist.highbyte=temp2 'convert it to word highbyte(16bits)
    dist.lowbyte=temp1 'convert it to word lowbyte (16bits)
    return

    logo:
    debug "OIL LEVEL MEASURMENT VER 1.0 BY VAMVAKOURIS",10,13
    debug "COPYRIGHT 2008",10,13
    RETURN




    error_sensor:

    debug "ERROR",10,13
    DEBUG "CANNOT COMMUNICATE WITH SENSOR",10,13
    DEBUG "CHECK THE CABLE",10,13
    PAUSE 10000 'wait 10 sec
    flag=0
    GOTO main




    error_sensor2:

    debug "LOST THE COMMUNICATION WITH SENSOR",10,13
    DEBUG "CHECK THE CABLE",10,13
    GOTO sensor




    wait_wireless:
    low wireless_tr_re
    debug "READY TO RECEIVE COMMAND",10,13
    serin2 wireless_rx_tx,84,10000,no_signal,[temp3,command]' 36="$" command=1
    if temp3=36 and command=1 then
    flag=1
    gosub sensor
    else
    goto error_data
    endif

    return



    no_signal:

    pause 10
    goto wait_wireless



    error_data:
    debug "WRONG START COMMAND",10,13
    DEBUG "CHECK THE WIRELESS COMMUNICATION",10,13
    PAUSE 100 'wait 100msec
    GOTO wait_for 'go and check again


    send_data:

    high wireless_tr_re 'enable transmit mode
    pause 2 'pause 2msec
    serout2 wireless_rx_tx,84,[dec 35,dist] 'send # and dist
    pause 2 'pause 2msec
    return

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Question

    Hi,

    Which Pic ??? , please ...

    may I suppose a 40 pins package ???

    Alain
    Last edited by Acetronics2; - 3rd March 2009 at 12:53.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default check your defines

    Hi
    Use CAPITAL LETTERS in your define for your OSC, that might fix the problem.
    Always use capitals in the defines and remember any problem or typo in the defines will not generate a PBP error.

  4. #4
    Join Date
    Feb 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    thanks for your quick reply's. sorry i forgot to write the pic. i am using 16f876A.tommorow i will try with capital the define's and i will inform you . i also thinking that may be timing because the garbage that i am receiving look like to be wrong baund rate

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


    Did you find this post helpful? Yes | No

    Default

    When switching from the PM assembler to MPASM, and not including config settings in your
    code, make sure your config settings in 16f876A.INC are the same for both assemblers.

    For a 12MHz oscillator both should use HS_OSC. XT_OSC may not be providing enough drive
    for your 12MHz crystal or resonator, resulting in some odd harmonic of the fundamental
    crystal frequency.

    That would for sure cause garbage to be displayed in a serial terminal. The actual PBP
    library code generated at compile time should be pretty much the same for either
    assembler. Both assemble the same library code.
    Regards,

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

  6. #6
    Join Date
    Feb 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Its workings

    the problem was the capitals....before i wrote DEFINE osc 12 and not working.when i changed to DEFINE OSC 12 it works fine.thanks everyone for their reply's.

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. About USB
    By dias11 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd December 2009, 20:41
  3. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  4. Debug and some 18F pics
    By sinoteq in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st June 2007, 15:10
  5. Converting to MPASM
    By btaylor in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2005, 01:35

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