In-circuit emulation and debugging for PIC

I'm trying to get off the ground with PIC's as a rank beginner -- although I have worked with micro's (6502, 6800) in the dim and distant past when I was not one of the dinosaurs roaming the earth....

I'm trying to decide between Microchip's ICD2 and the ICD-U-40 from CCS. I'll be using the CCS C compiler sometimes, other times I'll be working with assy.

Anyone have any suggestions on which way I should go? Can the more expensive ICD-2 do some things that the ICD-U40 cannot?

Reply to
Don Foreman
Loading thread data ...

This looks interesting.

I don't care about conformance to C standard because I don't need to be compatible with anything or anyone. I'm about 99% retired, want to use PIC's and C for some gadgets I've thought about for a long time.

Ease of learning and ease of use are my primary objectives. I don't yet know C and have never programmed a PIC, so ease of learning and availability of good tutorial material is important. I want math, trig functions and floatingpoint arithmetic which I assume are present in Wiz C. The "great" software emulator sounds very interesting.

Can you embed assy language code in Wiz C?

the IDE, never had to use an emulator. Other than a

Reply to
Don Foreman

Not sure about CCS, haven't heard anything good about it. I've been using WIZ C by Forest Elect. Dev. It has a great emulator built into the IDE, never had to use an emulator. Other than a bug or 2 ( they all have em) it was the best investment I made in a long time.

Plus it adheres to the C standard more so than the CCS.

Cheers

Reply to
Martin Riddle

I'd go for ICD2 if for no other reason that you know it will be the first to support new parts

Reply to
Mike Harrison

If you are familiar with the 6502 and the 6800 you might be better off with one of the modern Motorola micros like the 68HC11 - streets ahead of the PIC.

Ian

Reply to
Ian Bell

That doesn't sound good. Could I just skip the keywords and program the registers with inline assy code? That would blow portability but that won't be an issue for me. Other compiler you'd recommend in the same price range with a good user interface that isn't too cryptic? I don't want to have to learn a DOS-like command line compiler.

Good point. I need to walk before I run, though. My numbercrunching will be pretty modest. Example: accept data from a GPS and a digital electronic compass, compute an error vector from a stored location, produce signals to steer and throttle an electric trolling motor so it serves as a " virtual anchor".

I think I'll order an ICD2.

Hm! I have a "digital flatiron" I made, using a 4 x 5 x 1/2" piece of aluminum jigplate, an 800-watt heater from a 30-cup percolator, a type K thermocouple and a little Omega controller. Think that'd work for reflow? I have a syringe of solder paste in the freezer.

Yes. I ordered one yesterday.

I will definitely look at the AVR job as well. I've budgeted $1K for tools and miscellany to get going, since I just finished a job and have a few bux in the coffer.

THANKS!!!

Reply to
Don Foreman

I'm hearing a recurring theme here. I'm glad I asked!

I do have stuff for which the small PIC's really will be suitable, but I'm hearing that I may want to gain capability (eventually) with two families: the PIC's for small simple stuff and the AVR for projects where using C would be highly desirable in preference to assy language.

This old linear dog is having a hell of a time getting off the digital dime, but it's time to do it. Unnnnngggghhhh!

Reply to
Don Foreman

It's really not a matter of standard C. CCS does things a little different from other compilers, mostly in setting up the chip and peripherals. In assembler and most other C, you would set bits in control registers to, for example, setup a timer or PWM. There's a close correlation between the datasheet and your code. With CCS, you code a pseudo function call, but not really a function call. They are hard coded keywords in the compiler, a step even farther removed from closed source. If it doesn't work -- ECCP was still broken when my support contract expired -- you're relying on CCS to issue a compiler update. Hiding the details is good for portability, but is a frustrating hindrance when things aren't working. Their headers don't define registers or bit locations, making it difficult to code around problems. That aside, if you can ignore it, the code can be quite small and elegant, and easily retargetted at other chips within a family. I'm not a strong supporter, but the concept can work given time for the tool to mature.

Floating point and trig are probably not realistic for 8 bit microcontrollers. Certainly it can be done, but I rather view PICs as very flexible interface chips. A 32-bit ARM7 or dsp would be a better match for number crunching. I think you and the chips will be happier if you can separate device control from higher level decision making.

The boon and bane of software emulators is setting up the stimulus files. On one hand, you have very fine control and can setup conditions very accurately. On the other, non-trivial conditions take a bit of work to setup. In-circuit debugging is the more flexible alternative.

PICs are programmed in place through a five wire interface, ICSP. I put an RJ12 on most boards for this. A six pin male header is a direct fit for the PICkit2. I tire of routing the ICSP lines on single and two sided boards, and think from time to time of building a programmer on an 8-pin IC test clip.

In regards pin count and hand assembly, I get very good results reflowing in a wok on the kitchen stove. Solder paste can be had pretty cheaply; I bought a syringe for less than $20 recently. Stir frying causes far less heat stress than hand soldering.

If you're not firm on PICs, AVR is worth considering. I like the price of their development software: free if you use the GCC compiler. The PICC Lite (freebie) compiler doesn't support many of the interesting chips. If tool cost isn't a significant issue, you can be quite happy with either. If cost is a consideration, AVR has a slightly lower entry cost with, I think, better tools. I'm quite pleased with the $55 JTAG/ISP clone I bought. It debugs in place on chips that are capable, and programs the remainder through ISP. The ICD might not be such a good fit for the smaller PICs. You need specialized chips to debug in place. The PICkit2 is a reasonable alternative if you can/have to live without debugging. Self-powered on USB for $50 is not at all bad.

Starting out on a PIC, I would buy the PICkit2. It comes with a 16F690, protoboard, and 2 CDs of software and datasheets. For the AVR, I would buy MCPro's JTAG/ISP and the Butterfly. Download AVRStudio and WinAVR for free. The Butterfly has a 6 character LCD, piezo speaker, and joystick button, compared to the PICkit2's 4 LEDs, pot, and single pushbutton. $75 versus $50. Heck, get them both. :)

Reply to
Mike Young

On 08/12/2005 the venerable Don Foreman etched in runes:

If you are planning to work in 'C' then keep away from the PIC, which is really only suitable for assembler programming. Choose a micro that is specifically design for a high level language. The Atmel AVR is excellent and there is a large variety of both hardware and software support tools. Have a look at

formatting link

for a start.

--
John B
Reply to
John B

Wiz C has a demo availble.

formatting link

You can intermix C and Assmebler. Or go straight C or Assmebler. As Mike pointed out CCS has its oun way of setting registers. Wiz C is true memory maps. Define the links to the registers and use them in C. (much like Keil compiliers) Also Wiz C has its own semi GUI building blocks, not sure what you calll them. Place them connect them, set them and your finished. Neat, but you can forgo that method and do straight programming the old fashioned way. The simulator is nice. A intuitive GUI. You can even add devices to chip pins (leds etc) or define your own. Serial devices as well. Even stimulus files. You can even export to mplab. Ver 12 has a lot added. For $180, its really a steal.

I use a picpro programmer and David Tates software. Fored also has programmers and ICD's. Priced right too. And I use flash based parts.

formatting link
is a distributor. I Ordered thru them with out a hitch, stuff was here in NY with-in a week.

Support is very good too. If you find a bug, Robin is prompt is dealing with it.

Cheers

into the IDE, never had to use an emulator. Other than a

Reply to
Martin Riddle

CCS is uniquely priced among those supporting mid-range PICs. HiTech impresses me as worthy tools, but is about half your entire budget. Microchip's C18 is also pricey, but can be used for free on non-commercial projects with optimizations disabled. (For 18F chips, of course.) All integrate into MPLab; no command line stuff unless you want it.

Inline assembler is always possible, but you'll then have to manage the PIC's paged register addresses manually (one of their least endearing traits). There's no need to drop to assembler for that, however. uC compilers generally support bit and register operations directly. You only have to define where the registers are, and assign names for bits. Assembler won't simplify the task.

That's pretty lightweight, as you say; no problems there. Vector math on scaled integers, no floating point, should suffice. The most you might need is square root; I would try to get away from even that much.

The application sounds pretty cool.

That should work just fine. The heat mass of the 1/2" plate might cause temp overshoot, depending on where you put the thermocouple.

Reply to
Mike Young

...

Nice. The only thing better would be full integeration with PSPICE for simulation, but that would be too cool for mere mortals. Does the $180 include the simulator as well as the compiler?

Reply to
Mike Young

I use the CCS compiler, but I don't use any of their pseudo function calls to set up peripherals. I figured those were shortcuts for people who didn't want to bother learning how to do it themselves. The only bother is that I have to make my own header file that gives the register addresses for PORTA, etc. Then I just use regular C source (not assembly) to initialize peripherals, interact with them, and everything. I don't think the CCS approach has restricted me in any way. It only takes a few minutes to make up a header file containing the registers that you want to reference.

-Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

This is all very helpful. I'm printing your helpful messages. I'm back to thinking I might try the CCS C compiler for simple PIC projects that use a little math (like a tachometer), looking at Atmel for more ambitious projects. A large appeal to the CCS compiler is that it looks very easy to learn and use, and that 's worth a few bux to me. I don't expect to get everything right first go but I wanna get off the dime. I've been paralyzed for over 5 years. If I can't get off the dime with native wit, youthful vigor and dazzling intelligence, then I'll throw money at it, dammit! Shovel ain't workin', fire in the hole sort of approach. I've budgeted $1K to get my feet wet with microcontrollers.

The thermocouple in the digital flatiron is within .030" (0.75 mm) of the plate surface, right under the heater, in a well filled with Omegabond 101. Even with the 800-watt heater and about no effort at tuning the PI control, it doesn't overshoot more than a degree or two. Regions more distant from the heater probably lag a bit.

I made it for use with PNP blue, "ironing" laser-printed patterns for PC boards. It worked better than anything else I tried, but still didn't work as well as I'd hoped and not well enough. I now use pre-sensitized photo for simple one-sided boards and budgetPCB for good double-sided boards with plated-thru holes. I do layouts and simple boards even for simple circuits because I've never been a good technician, about can't handwire a doorbell without screwing something up. But I can usually get a schematic right. PCB software checks layout against schem; when it's happy, all I need do is drill some holes, stuff some parts and sling some solder. I sling solder just fine. I even get the parts stuffed right-side-up most days. Current adventure with this is control elex for my four-Luxeon microscope ringlight for use in working with SMT parts. It's all linear, could be an excellent candidate for a microcontroller project: control brighness of the individual lights with a joystick and slewing button to PWM the current sources. I'm presently using pots. It works, but a joystick would be more intuitive to "drive".

I'm an old linear circuit designer and research puke, more recently a half-decent machinist and weldor. I do appreciate your patience and help with my efforts to get my feet wet with microcontrollers.

Reply to
Don Foreman

That is very encouraging. Thanks.

By the way, where (in general) do you live in Ypsi if you don't mind my curiosity. I grew up in Ypsi many years ago. Went to Roosevelt HS which was closed down some years ago. I lived on Collegewood Drive a bit west of Cornell, which was a gravel road at the time. Both of my folks worked at EMU, which was Michigan State Normal College then. In those days there was nothing behind us clear to the Huron river. I spent many pleasant summer afternoons plinking crows with my .22 rifle (bolt-action Mossberg carbine) not far from my back door. The bike and walking path that is now there was once a railroad we called the "try-weekly" because they tried to use it once a week or so. The roadgangs would return our waves with a grin and turn off their weedsprayers when they passed our garden that was really on the railroad's land. My dad and I kept the weeds cleared with weedwhips.

A well- honed, well-swung weedwhip actually takes less effort than a gas-powered string trimmer and it makes no noise at all -- other than the bitching of the boy pressed into service swinging it.

Reply to
Don Foreman

memory maps. Define the links to the registers and use

Place them connect them, set them and your finished.

fashioned way.

(leds etc) or define your own. Serial devices as well.

$180, its really a steal.

and ICD's. Priced right too. And I use flash based

stuff was here in NY with-in a week.

Printed for study. This looks good. I don't have a picpro programmer and I know zip about David Tates software. Do I need to know more in order to use Wiz C?

Reply to
Don Foreman

To echo what others have said: CCS is a bit cheaper and easier to use than the alternatives if you are interested in PIC16 parts. But after using a few big PIC18 parts recently (PIC18F8722 for example), I've decided to switch to them. There are usually PIC18 parts you can use to replace a PIC16 part, sometimes for less money. The only real exception so far seems to be in the smaller chip sizes (8 pin thru 16 pin).

If you use PIC18 chips you can use the C18 compiler from Microchip, which is free for non-commercial use. It's a bit harder to use than CCS in that you pretty much have to figure out register initialization and usage all on your own, but it's not that hard to do. And CCS' "functions" have enuff bugs in them that you often have to resort to looking at what their code is doing to registers anyway. Interrupts are more painful to deal with in C18 than in CCS. Stay away from them till you feel more comfortable using the compiler.

I just recently bought an ICD2 after several years of using the "delux" CCS toolset PCW. PCW includes an editor, compiler, and interface for the CCS ICD (note: PCW does not work with Microchip's ICD2). When I started using PCW it was more advanced and more stable than MPLAB (Microchip's free IDE). But MPLAB has improved. It's latest emulator really rocks. You can do a pretty good job of debugging code without ever burning a chip. You should consider looking at C18 and MPLAB. You don't even need to buy an ICD2 until you're sure the compiler is working for you.

Happy coding,

Mark

Reply to
mhahn

Wiz-C looks pretty good, too, at not much more than CCS. Definitely give it a look. I somehow missed them entirely when I was tooling up.

The PICkit2 assembler tutorial is useful. That'll get you off the dime fast.

Have fun, Don. Drop a note if you wish; the email addr is real.

Reply to
Mike Young

Yes, I've heard of Collegewood and Cornell and the bike path along the old railroad. But I don't live in town, and my memory doesn't go back as far as yours. I came to the area in '66 when I started at U. of Mich.

-Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

Last time I looked at Moto, the cost per part resulted in them being scratched from my list. I thought the HC11 was on its way out anyway?

Reply to
The Real Andy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.