Archive for the MPLAB 8.00 Category

Visualizing Data - A taste of Visual C#

Our brain is wired for image processing and all things visual just reach deep in our mind faster! If there is one moment when I just cannot seem to ever get enough of a “view”, that’s when I am debugging code. The Watch windows, the local variables windows, the stack window are not what I am talking about. The Logic Analyzer window (in MPLAB SIM) and the DCMI (with simulator and emulators) are barely starting to scratch the surface, when I need to debug some complex code, I am willing to use literally everything at my disposal, beyond MPLAB, using hardware (scopes and logic analyzers) but also additional software.

Read the rest of this entry »

Visualizing Data - DMCI

I guess one of the advantages of getting older (if there is any) is that I am becoming somewhat more patient and I am learning to resist the temptation of trying out on the hardware target every single line of new code I write. I am finding myself using the simulator (MPLAB SIM) more and more every day to test thoroughly sections of my code before throwing it out to the ICD. The result is overall less development cycles (code, program (ICD), run, crash, … repeat), more bugs caught early and more productivity.

Read the rest of this entry »

Look Mom No … Linker Script

There are so many new features being added to MPLAB at each major (and minor) new release that I struggle to keep up. Just a couple of days ago for example, I was discussing with a colleague how it would be nice to have the MPLAB New Project Wizard to use a default linker script in every new project … so that in most standard cases the repetitive  task of adding one (navigating through the many subdirectories inside Program Files) can be spared and … I got stopped mid-sentence and promptly reminded that this feature was already there! In fact since last November, with the introduction of version 8.00, MPLAB has been quietly offering a default linker script when the MPLAB C30 toolsuite is selected.

Thanks !

Watching Expressions

MPLAB has become such a large application, or I should better say “group” of applications, and it keeps evolving so fast that one can hardly keep up with the pace of monthly (when it is not weekly) updates. Typically before rushing to install a new version I scan quickly through the readme files to see if there is anything new that I could use immediately, otherwise I tend to postpone the update to let it … settle a bit, if you know what I mean.

With MPLAB 8.00 things were different. The PIC32 had just been announced and this was the first new version of MPLAB to openly support it. I was too curious to pass the opportunity and I did the install without paying much attention to what other features had been added.  Turns out, I made a mistake because I failed to notice a powerful update to the Watch window capabilities!

Now you can inspect/watch:

  • Aspecific element of an array: ar[12]
  • An object pointed to by a pointer: *ptr
  • An element of a structure/union: str.mbr
  • An element of a structure/union via a pointer: p->mbr
  • Perform simple math: vrbl-1
  • Use constants defined in the program in all of the above: ar[M_SIZE-1]

Just type these simple expressions directly in the watch window in the Symbol Name column

Watch Expressions

it will work seamlessly allowing you to get a better picture of your… bugs!

Updating Chapter 4

There are no changes required to the code in chapter 4 after the upgrade to MPLAB C30 v.3.02. But there are some changes in MPLAB 8.00 behavior that will have you puzzled when looking for the subroutines (library modules) used by the compiler for the long long (64-bit) integer multiplications.

In fact, the listing in the Disassembly window will not show anymore the long long multiplication routine muldi3.c as MPLAB 7.40 and older versions did. In a way the Disassembly listing has been cleaned up a bit, but don’t despair. If you follow the next few steps you’ll be able to find the missing routine anyway:

  1. Take note of the subroutine address, the number after the rcall mnemonic:
    (00280 in my case)
    long long mul
  2. Open the Program Memory Window and make sure to select the Symbolic view
    (use the tabs at the bottom left corner of the window)
  3. Press CTRL+F to open the search dialog box and type the address (00280) or simply scroll down the window until you reach the address.
    00280
  4. There you will recognize the label __muldi3 marking the entry point of the 64-bit multiplication routine used by the compiler. (That’s pretty dry reading, isn’t it?)

Looking at the exercises proposed in Chapter 4:

  1. Using Timer2 to self time the number of cycles used by each arithmetic operation is just a good idea. Exercise 4-1
    Most/all operations will fall withing the 16-bit resolution of the timer (within 65,536 cycles) so that it is easy to obtain all the cycle counts in a single watch window shot:
    multiplications
    Notice how some of the values changed a little bit since version 1.30 of the MPLAB C30 compiler?
  2. Checking all the divisions at once is just as simple now: Excercise 4-2
    Here are the results:
    divisions
    Do you notice anything interesting? Who said float math has to be always slower than integer?
  3. Trigonometric operations (sin()) is performed using polynomial approximations and therefore multiple additions and multiplications. This has to be “hard”… Excercise 4-3
    trig
    Looking at these numbers you can almost guess the order of the polynomials…
  4. Complex math as well is composed of multiple operations of the fundamental type (integer/float): Excercise 4-4
    complex

|