PDA

View Full Version : Converting to MPASM



btaylor
- 3rd November 2005, 05:04
I have never used MPASM, always PM that comes with PBP. I have a 500 line program that compiles and runs perfectly under MicroCode Studio Plus with PBP 2.46 and PM but when I try and use MPASM my system falls apart. The PBP program using PM compiles to 2512 words - with MPASM it generates 3444 errors. That is an average of 5 errors per line of program code. Not what I had in mind.

I downloaded MPASM v02.15 from the MicroChip site & unzipped it to its own directory. I pointed MCSP to the appropriate directory in View/Compile and Programme Options. I read the MCSP help. I checked the MPASM notes in the PBP manual. Still got 3444 errors.

Can someone please point me at the basics of using MPASM? Are there settings outside MCSP that need tweaking? Must all commands be in upper case? Do I need a blank at the start of evry line? There has to be a fundamental something I am missing.

For example the following few lines work in PM.

@ Device pic16F877, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF

trisa = %11111111
trisb = %11111111
trisc = %10011111

But in MPASM I get the following error messages (text abbreviated)
16F877.inc..unknown processor (16F877)
Cannot open file (include file "16F877.INC" not found)
Processor type is undefined
Duplicate label ("_PORTL"..........)
Symbol not previously defined PORTC
Symbol not previously defined TRISB
Symbol not previously defined TRISC

I have started reading the MPASM manual but at 278 pages that will take a while.

Any tips greatly appreciated.

thanks
Brian

Melanie
- 3rd November 2005, 06:59
Pretty much the ONLY difference between PM and MPASM are the Configuration Fuse Definitions. There is a thread in the FAQ section on this topic. Get those right and you're in business.

btaylor
- 3rd November 2005, 09:21
Hi Melanie,

Thank you for the prompt assistance. I had in fact read your post on configuration fuses in the FAQ prior to my message. I should have mentioned that. Sadly it did not cut it for me.

For example I took the line in PBP
@ Device pic16F876A, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF

and re-wrote it to suit MPASM as
@_config_HS_OSC &_BOD_OFF &_PWRT_ON &_WDT_ON &_PROTECT_OFF

The error count on compiling under MPASM jumped from 3444 errors to 6259 errors - hardly a leap forwards.

Must I cover EVERY fuse in the chosen controller? Can some be left as don't cares or whatever the default is?

Can I explicitly declare the processor type in the @_config_ line in MPASM? A project at the moment has three separate interacting parts with three different processors and jumping between them occasionally calls up the wrong controller. PM lets me know - can MPASM do that?

Is there some magic at the start of the @_config line? Is it @__config or @ __config. Must it start in the first or second column or what?

Cheers
Brian

Melanie
- 3rd November 2005, 10:20
Firstly, it's really ONLY the CONFIG settings... so nail those and your problems will disappear. If you comment-out all your defines, you'll probably find that the chances are you'll compile without error with a set of defaults. Now, Microchip are changing their config declaration syntax, so this all depends on the version of MPLAB/MPASM you've got. So that we're playing in the same ball-game, go download the LATEST version of MPLAB/MPASM, then come back, tell me you've done it and also tell me the Config Setup's you need. I'll then walk you through it with that example...

btaylor
- 3rd November 2005, 11:00
Melanie, Thanks for the prompt response. I first went to microchip and on their home page typed MPASM into their search bar. It took me to a page where I downloaded what appeared to me to be the latest versions of MPASM. MPASM™ Assembler Last Updated: 7/21/03

Following your advice, I have now tried again to find MPASM but this time went into the QuickLinks search bar and clicked on the development software area where I can find MPLAB IDE ver 7.20 and 7.22 but no direct reference to MPASM. I am downloading this monster now, but it will take a while.

I did try commenting out the @_config_ line earlier but no joy. You are probably right in suggesting a version issue. The MPASM I am downloading is version 5.00 which is included in MPLAB 7.22. Does this look like the right version?

Cheers
Brian

Melanie
- 3rd November 2005, 11:55
MPASM is a component part of MPLAB. MPLAB 7.22 is the latest at this time containing MPASM 5.0 of 30 September 2005.

btaylor
- 3rd November 2005, 20:48
OOPS a duplicate some how.

btaylor
- 3rd November 2005, 21:37
Hello Melanie.

As you suggested, I went to the microchip homepage and clicked QUICKLINKS then Development Software and downloaded the 38 Mbyte zip file of MPLAB IDE ver 7.22 which I believe to be the latest version. MPLAB includes MPASM.

I unzipped this into a directory C:\MPASM. From that directory I clicked MPLAB_v722.exe and let it install the full MPLAB system to the default directory C:\program files\microchip\etc.

I then loaded MicroCode Studio Plus, (ver 2.2.1.1) and clicked view\Compile & Programme Options then made MPASM as the default compiler. MPASM was found automatically.

I am running PBP ver 2.46 and have an incomplete, but running, program of 370 lines. The target processor is a PIC16F877 and I am using the MCSP Bootloader to program the chip. This compiles under PBP/PM to 2715 words with no errors. The first few lines of this program are attached.

Under PBP/PM, the following configuration line is active.
@ Device pic16F877, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF

To suit MPASM, I changed this to
@ _config_HS_OSC &_BOD_OFF &_PWRT_ON &_WDT_ON &_PROTECT_OFF

I get 1259 errors when I try to compile under MPASM, zero errors under PBP/PM.

CHeers
Brian

Here is the start of the program. This snippet does compile under PBP/PM but not under MPASM.

data @0, "DeckUnit v5.00 BDT 3 NOV 05 "
data @30, 01, $E0, $15, 200, 50 ' ID, Fcntr.lo, Fcntr.hi, Fdev, bitrate
data @35, 0, 5, 12, 48 ' MasterSlave, matches, syncbits, repeats
data @39, 0, 60 ' TxPower, sleeptime

'************************************************* ********
'* Name : DeckUnit500.PBP *
'* : *
'************************************************* ********

DEFINE OSC 20
DEFINE loader_used 1
DEFINE CHAR_PACING 1000
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 5
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 500

@ Device pic16F877, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF
'@ _config_HS_OSC &_BOD_OFF &_PWRT_ON &_WDT_ON &_PROTECT_OFF

trisa = %11111111
trisb = %11111111
trisc = %10011111
trisd = %00000000
trise = %00000000
OPTION_REG = %10001111 ' no pullups, prescaler to WDT /128

'***************** Hardware definition **********************
DiagLED var porta.0 ' Olimex standard LED
GoLED var portc.5 ' pin 24 on '877

'******************* Software variables **********************
A var byte
B var byte

'*************************** Initialise ********************************
Startup:
Initialise:
OPTION_REG = %00001111 ' no pullups, prescaler to WDT /128
INTCON = %00000000
PIE1 = %00110000
PIE2 = %00000000 ' guessing here
ADCON1 = %00000111
TRISE = %00000000
CCP1CON = %00000000

TestLED:
for a = 0 to 9
high goled
high diagled
pause 100
low goled
low diagled
pause 100
next a
trisa = %11111111

btaylor
- 4th November 2005, 00:09
My problems with MPASM appears to be a path, path length, or similar problem. Plus a remnant @ _config_ issue.

I found a comment on the PICBasic List.

(quote) When ever I use MPLAB I make sure there is a full copy of PBP in the Mplab directory and place my PBP program in the directory too. This prevents all
the problem with paths etc. (endquote)

I also found other comments that the total path length must be short so I shifted my code from 'my documents' up to an entry in c:\ and I copied all my PBP files to c:\program files\microchip\MPASM Suite.

It nearly works now. I still get errors when I use the line
@ _config_HS_OSC &_BOD_OFF &_PWRT_ON &_WDT_ON &_PROTECT_OFF

If I comment that line out completely I get no errors, just warnings about page boundaries which I assume PBP has taken care of for me. I would rather have the explicit configuration line active.

Nearly there maybe. What a drama.

Cheers
Brian

Darrel Taylor
- 4th November 2005, 00:30
Hi Brian,

In the CONFIG line for MPASM, there must be 2 underscores before the word CONFIG, and a space after it. And some of the options should be different


@ __CONFIG _HS_OSC &_BODEN_OFF &_PWRTE_ON &_WDT_ON &_CP_OFF


And keep in mind that MPASM is CASE Sensitive (unless you use the command line option to disable case sensitivity).

HTH,
   Darrel

btaylor
- 4th November 2005, 01:23
Thanks Darrel,

I copied your line into my code. It tellls me I now have 2 errors but only one error gets shown with three messages on the bottom of the MCSP screen.

Error [118].....Overwriting previous address contents (2007)
Message [306] Crossing page boundary..ensure page bits are set.
Message [306] Crossing page boundary..ensure page bits are set.
Message [306] Crossing page boundary..ensure page bits are set.

Do the page bits get set autometically?

What does error 118 mean and how do I fix it?

Brian

Darrel Taylor
- 4th November 2005, 01:35
2007 is the address of the CONFIG word in the PIC. The "error [118] Overwriting previous address contents" means that it's already been set.

In the 16F877.inc file in your PBP folder, comment out the __CONFIG line with a semicolon ";" Then try again.

Just remember, that once commented, every time you write a program for a 16F877, you''l need to have a CONFIG line at the top of your program, since the defaults aren't there anymore.

You may also want to add _LVP_OFF to the CONFIG in your program to turn off the Low Voltage Programming input.

And <b>@ errorlevel -306</b> will turn off the Crossing page boundary warnings
<br>