MPLAB ICD2 Problem

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

MPLAB ICD2 Problem

Post by dmtulsa » Fri Jun 27, 2008 7:03 pm

I'm a little confused on setting maxram and maxrom

From the app note:



The number of bytes reserved vary from device to device. The values shown above are for the 18F1320, which can be found in the MPLAB online documentation under "HELP...TOPICS...MPLAB ICD2...Resources Used by MPLAB ICD 2". The DEBUG = true configuration fuse is used for ICD. It is very important that the DEBUG configuration is not used if you are building release code or you are not going to use ICD. If this fuse is enabled, your program will not run outside of the ICD environment. The best thing to do is create an #option, so you can easily enable or disable ICD. This is the code I used in the "Junebug.bas" module, shown later:

// if you want to use ICD, then set '#option ICD = true' in your main program
// before you include this module...
#if IsOption(ICD) And ICD
#option ISR_SHADOW = false
#variable _maxram = _maxram - $C // constrain RAM
#variable _maxrom = _maxrom - $1C0 // constrain ROM
Config DEBUG = ON // DEBUG fuse ON

Where does $C and $1C0 come from? In the MPLAB ICD2 Help/Resources for the PIC18f1320 it says PIC18F1320 0x1E40-0x1FFF 0xF4-0xFF How does that relate to $C & $1C0 ??

I must be looking in the wrong spot or something. I need a bit more info I think. I'll be working with a 18F8722

Thanks
Doug[/quote]
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Fri Jun 27, 2008 7:57 pm

Again I'm new at this and I get a breakpoint could not be resolved no matter what line I put the breakpoint on.

The IDC2 is working fine, it builds fine and I can step thru the ASM listing. I'm thinking its related the my prior post above.

Code: Select all


Device = 18F8722
Clock = 10
#option ICD = true
// if you want to use ICD, then set '#option ICD = true' in your main program
// before you include this module...
#if IsOption(ICD) And ICD
#option ISR_SHADOW = false
#variable _maxram = _maxram - $C    // constrain RAM
#variable _maxrom = _maxrom - $1C0  // constrain ROM
Config DEBUG = ON 
#ENDIF
#option TRISD=0
// blink an LED, PORT bit is passed by
// reference to the subroutine...
Sub Blink(ByRef pBit As Bit, pDelay As Byte = 50)
asm ''added just to test 
	nop 
end asm
 High (pBit)
   DelayMS (pDelay)
   Low (pBit)
   DelayMS (pDelay)
End Sub

// loop counters...
Dim Index As Byte

// main program...
While true
   For Index = 0 To Bound(PORTD.Bits)
      Blink(PORTD.Bits(Index))
   Next
Wend 
Any Ideas?

Doug
Doug
kd5nwk

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Fri Jun 27, 2008 8:50 pm

> I'm a little confused on setting maxram and maxrom

Take _maxram as an example (0xF4-0xFF)

0xF4 = 1
0xF5 = 2
0xF6 = 3
0xF7 = 4
0xF8 = 5
0xF9 = 6
0xFA = 7
0xFB = 8
0xFC = 9
0xFD = A
0xFE = B
0xFF = C

or

maxram = maxram - ($FF - $F4 + 1)

> Again I'm new at this and I get a breakpoint could not be
> resolved no matter what line I put the breakpoint on.

I am assuming you are using the latest version of the compiler (2.1.0.0) and MPLAB 8.1. Forget ICD at the moment and enter the following program:

Code: Select all

Device = 18F8722
Clock = 10

// blink an LED, PORT bit is passed by
// reference to the subroutine...
Sub Blink(ByRef pBit As Bit, pDelay As Byte = 50)
   asm ''added just to test
   nop
   end asm
   High (pBit)
   DelayMS (pDelay)
   Low (pBit)
   DelayMS (pDelay)
End Sub

// loop counters...
Dim Index As Byte

// main program...
While true
   For Index = 0 To Bound(PORTD.Bits)
      Blink(PORTD.Bits(Index))
   Next
Wend 
From the MPLAB main menu, select DEBUGGER...SELECT TOOL...MPLAB SIM. Next, build your project. It should display something like the following after building:

Swordfish BASIC Compiler (SE) 2.1.0.0 Copyright (c) 2007 Mecanique
All Rights Reserved.
ROM used : 276 Bytes (0.21%)
RAM used : 38 Bytes (0.97%)
Loaded C:\Documents and Settings...
BUILD SUCCEEDED: Fri Jun 27 21:36:53 2008

IMPORTANT

MPLAB sometimes gets all confused with its breakpoints, so right click on your program windows and select: BREAKPOINTS...REMOVE ALL BREAKPOINTS. Press the simulator 'Reset' toolbar button for good measure. Now put a breakpoint on this line

Code: Select all

      Blink(PORTD.Bits(Index))
and then press the Run toolbar button. Let me know how you get on...

User avatar
blueroomelectronics
Posts: 46
Joined: Mon Apr 23, 2007 3:48 pm
Location: Toronto
Contact:

Post by blueroomelectronics » Sat Jun 28, 2008 4:20 am

I tried the debugger but get this error
The language-tool suite "Swordfish BASIC Compiler" does not appear to have a linker.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Jun 28, 2008 8:43 am

You might want to try creating a projcet "from scratch" using the following guide:

http://www.sfcompiler.co.uk/wiki/pmwiki ... r.MPLABICD

> The language-tool suite "Swordfish BASIC Compiler" does not
> appear to have a linker.

Make sure you only have your main program file in "source files". Do not include any modules (add modules to "Other Files")

Let me know how it goes...

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Mon Jun 30, 2008 1:45 pm

David,

i did as you posted above. the program compiles correctly in the sim. The program compiles and runs correctly using normal mplab "program". It also runs in debug. In debug I can set breakpoints in the disassembly listing but not in .bas listing. I have cleared and reset the breakpoints.

MPLAB Ver is 8.10 SF Ver 2.1.00-ICC 1.1.5.1

#variable _maxram = _maxram - $C // constrain RAM (0xEFF - EF4 +1 =0x0c)
#variable _maxrom = _maxrom - $280 // constrain ROM (0x1FFFF - 0x1FD80 + 1 = 0x280)

So, Everything seems to be OK except the breakpoint

Any Ideas

Thanks,
Doug
Doug
kd5nwk

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Mon Jun 30, 2008 2:37 pm

You will need to send me a sample program showing this problem. Include all your MPLAB project files. Importantly, email

SFBasis.mtc
TLSFBasic.ini

which can be found in your MPLAB "MTC Suites folder". For example,

C:\Program Files\Microchip\MPLAB IDE\Core\MTC Suites

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Mon Jun 30, 2008 3:02 pm

Files received, thanks...

The problem is with your "TLSFBasic.ini" file, which is documented here:

http://www.sfcompiler.co.uk/wiki/pmwiki ... r.MPLABICD

under "Swordfish as a Language Toolsuite". In short, you need to download the new files from here

http://www.sfcompiler.co.uk/wiki/pmwiki ... User.MPLAB. Copy to your MTC folder and verify that "TLSFBasic.ini" now has "Debug=COF" AND NOT "Debug=COD"

Please let me know if this works for you...

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Mon Jun 30, 2008 9:18 pm

I did that the other day but must have messed up coping the files or something. Anyway I re downloaded the .ini & mct files and put them in the mplab ied/core/mct suites.

I still have the same problem.

I emailed you ALL the files again.

Thank you
Doug
kd5nwk

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Mon Jun 30, 2008 11:02 pm

I'm not seeing the problem here I'm afraid - I rebuilt your project and it simulated fine using 2.1.0.0 and MPLAB 8.1. Try importing the *.cof file directly into MPLAB and see if that works...

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Tue Jul 01, 2008 1:25 pm

David, I got it to work. I had to run Swordfish.reg again after updating the .ini & .mct files

Thank you for your help
Doug
kd5nwk

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Tue Jul 01, 2008 1:48 pm

Brilliant news, thanks for keeping me posted...

Post Reply