PDA

View Full Version : debug not working with MPASM assempler



santamaria
- 3rd March 2009, 11:45
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

Acetronics2
- 3rd March 2009, 12:50
Hi,

Which Pic ??? , please ...

may I suppose a 40 pins package ???

Alain

sinoteq
- 3rd March 2009, 13:23
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.

santamaria
- 3rd March 2009, 19:52
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

Bruce
- 3rd March 2009, 21:43
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.

santamaria
- 4th March 2009, 07:51
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.