:: Home :: Code Snippets :: Drivers :: Projects :: About ::
 Main Menu
  Home
  Code Snippets
  About

 Open Drivers
 EA-DOGM - LCD Display Driver
 PIC32 mcompat - PIC32 mcompat
 qTask - Queued Task Manager
 _build - Embedded build information

 Open Projects
 fplCore - Self contained controller
 uProfiler - uController uProfiller
 oLogic - Oscilloscope Logic Viewer
 oLogic 1.4 - NEW Logic Viewer
 SSX32 - Serial Servo Driver



 Sources
Prototyping
  PicStuff
  Sparkfun

Equipment
  Saelig
  Tequipment

Supply House
  Jameco
  Mouser
  Digikey
  Allied Electronics
  Clearwater Technologies

Miscellaneous
  BCM
  N34D Blog

uProfiler
Times various internal functions and code sections







uProfiler

The uProfiler is a hardware based profiler that you can use to debug your uController project.

This profiler connects to your PC via USB, and apears as a CDC Serial port.

Connect to this serial device with an ANSI Color terminal.

I had been using a few pins connected to my scopes to measure pulse widths so I could measure various loops and functions, and sending debug info into a terminal.

Then I saw the code profiler built into CCS C compiler, I tried to reverse it a bit, as I didnt have their ICSP programmer. Then I just decided to dive in and put something together that would not tie down the PIC, and something I could remove from source very easily.


Checkout the usage.txt file listed on the right.



In your code, include the uprofiler.h file, and insert various pieces of code into your source
and you can debug the following:

  • Determine main loop running time
  • Time various functions (up to 16)
  • Time various sections of code (up to 16)
  • View up to 16x 8 bit variables or 8x 16bit variables
  • Inc/Clear 15 counters
  • Set and Clear 16 flags
  • Turn on/off 5 LED's (also displays on screen
  • Set a State output (useful for state machines or status)


All this with very little impact on your C source code. All measurements are done in the uProfiler, as well as all the ANSI color output. Just connect to an ANSI Serial terminal.


We take the generaly unused pin B7 (Microchip uControllers)
and create a BitBang'd serial output from it, and use that to feed
the uProfiler.

The overhead your C program incures is minimal, just the time it takes to bitbang 1 byte for most of the profiler functions.

Exceptions are viewing variables, that sends 3 bytes for 8bit, and 6 bytes for 16bit.

It is easily possible to modify the header file, and use a hardware UART to lower the impact.

Note: Great pains were taken to tune the timming functions within the uProfiler. We are accurate to within +/- 15us. Now I know that a super critical loop can be lower than this. If you need super accurate timming, please, use a dedicated pin and a scope.

Note 2.0: There may be a pin timing input on this project in the very near future


Here is an example:

#include

#define UPROFILER_BAUD 19200 #include "uprofiler.h"

void blink(void)
{
   uProfState(0x02);
   uProfFlagSet(0x01);

output_high(PIN_B5); delay_ms(50);

uProfState(0x03); uProfFlagClear(0x01);

output_low(PIN_B5); delay_ms(50); }

void main() { unsigned int16 x,y,z;

uProfReset();

while(TRUE) { uProfMain();

uProfWord(0xABCD,2);

uProfLedOn(0x00); uProfState(0x01);

uProfCounter(0x00);

uProfSecStart(0); x=5000; y=200; z = x/y; uProfWord(z,6); uProfSecEnd(0);

uProfFunStart(0x00); blink(); uProfFunEnd(0x00);

} }
 Project Specs
sw ver: 1.1
mcu: 18F2553
compiler: CCS C

 Parts
PIC: 18F46K20
All Caps: .01uF

 Files
example.c
uprofiler.h
uprofiler.zip
uprofiler-terminal.jpg
source-1-2.zip
usage.txt
main.hex
uprofiler-schematic.jpg

uprofiler.zip - All files






:: Home :: Resources :: PIC Microcontrollers ::
:: 10F :: 12F :: 16F :: 18F :: 24F :: 24H :: 30F :: 33F ::
(C) Copyright 2009 mculabs.com - contact: info@mculabs.com
0.0026400089263916