home » HC12/HCS12 resources » PODEX copy

PODEX - my own copy with enhancements and bug fixes

UPDATE:

[2007-02-11] Due to AT90S2313 being out of production, it can be replaced with ATTiny2313. It allows for faster clock frequency, so 25MHz target (MC9S12NE64) is completely legal now. There's new firmware allowing for any target clock (up to 2x PODEX crystal), but old firmware for AT90S2313 can also be used if needed, please see notes below.

General information

PODEX is a BDM POD for Freescale HC12 MCUs. PODEX was designed and build by Marek Peca, and all credits for this work go to him:

www: http://www.duch.cz/podex/
e-mail: marek@duch.cz

On his site, Marek publishes all needed documentation for building your own copy. I made small changes: first of all, it uses ICs in DIL packages instead of surface mount - so it's easier to build for hobbyists. DIL packages are also handy for swapping out MCUs when looking for the one working happily when overclocked (if using AT90S2313, now with ATTiny2313 this is no more the issue). Last, it's easy to replace MCU when it goes bad (and it happens accidentally, with too high voltage at Vcc). Second, there's additional protection on RS232 side. Third, added fifth pin to the programming connector, for easier connection of programming cable. That's really minor. But when doing my own board, I could, so I did.

PODEX is designed to be protocol compatible with Kevin Ross' BDM12 Pod. This protocol is far from perfect, but has one advantage - is supported by some tools, so using it we're making our POD somewhat compatible and supported out of the box. PODEX is build using simple AVR MCU - ATTiny2313 or AT90S2313 (now out of production). For more details, please look at authors www page, there's very detailed description.

Schematics

Schematics were redrawn fro scratch, because it was needed to automate the board design (netlist, etc). This is the same as Marek's schematics, with some slight changes: added protection TVS diodes on RS232 lines, ground connection for programming cable, and skipped external clock feed through BDM connector, which I find not needed. Rest is 100% the same.

Schematic below shows AT90S2313 MCU + 9.216MHz crystal, but read the notes below regarding MCU and crystal frequency selection.

AT90S2313: one thing worth noting is crystal selection. Schematic shows 9.216MHz, and that's good "default". Crystal frequency has impact on two things: RS232 baud rate and maximum HC12 target speed. Because BDM communication speed is much higher that RS232, we want highest RS232 baud rate available, that usually is 115200bps. To achieve such rate, we need specific crystal frequency, one that will evenly divide into 115200. AT90S2313 has theoretical XTAL limit at 10MHz, that means 9.216MHz crystal is good here. It also limits target HC12 speed to around twice that. That's good for targets up to 16MHz and maybe slightly more, but not enough for targets > 20MHz. Almost for sure 11.0592MHz crystal can be used, I think every AT90S2313 will happily work with such frequency (despite being only 10MHz, even Atmel publishes official datasheet with divisor values for serial baud rates when using 11.0592MHz crystal, so take that frequency for granted). My last project utilizes MC9S12NE64, where 25MHz is needed for ethernet to work. I had to make PODEX faster, and that led to 14.7456MHz crystal. Anticipating this, I made the board for DIL chips, that enabled me to try some chips out. I had good luck with overclocking, I had few pieces of AT90S2313 and every all worked fine. Notes on the firmware for such frequency below. One thing observed with such overclocking is higher noise susceptibility. Certainly not applicable for harsh environments, but works well on the desk.

ATTiny2313: this is a no brainer - 14.7456MHz crystal does the job, MCU works up to 20MHz. If there's need to use faster clock, it's possible, but requires firmware change. Supplied firmware is working with 14.7456MHz. It's also possible to use slower clock, for example when using 3.3V power supply - ATTiny2313 is specified for 10MHz @ 3.3V. This is the same as 90S2313 at 5.0V, so please read the notes above - about possible overclocking, if needed.

This is BDM cable for connecting to the HC12 chip. There are two versions: first, most popular - uses 6 pins; second - with addition of MODA and MODB lines. This cable cannot be too long ! Otherwise there will be problems with transmission reliability. I wouldn't exceed 10cm, shorter is better.

There's also cable for connecting PODEX to PC's parallel port for AVR MCU programming. Added pin for ground connection eases connection, without using ground connection via RS232 cable. This cable also cannot be too long, because it'll prohibit successful AVR programming. I had no luck with cable 1 meter long. Making it 20cm did the job.

PCB

PCB is simple - two layer board, all through-hole instead of SMD. For bill of materials, consult Marek's page, or just use the schematic. Below are the drawings of routing on both sides of the board.

Most interesting image is assembly layout:

If you want to make your own copy, you can download post-process files for PCB production using link below. Included are: top and bottom routing layers, solder mask for top and bottom, silk screen for top layer. Solder masks and silk screen are optional, without them the board will be cheaper, but less pretty.

PDFs for print

If you want to print some of the above, here are PDF files for printing in somewhat better quality than above images.

Firmware

Firware, as whole PODEX design, is written by Marek Peca. Remember, it's his work, not mine :) Original firmware is available from Marek's www page, but in this form it has some bugs. I made some fixes and few variants of firmware, details follow.

Bugs: as I was writing some own software to control the PODEX, I discovered some bugs in firmware, which stood hidden when using PODEX with GDB. Bugs are in memory block transfers, both reading and writing. Also setting extended speed (something different than 2/4/8/16MHz target HC12 MCU frequency) sometimes doesn't work - depending on the frequency. I didn't manage to investigate it further yet ... I made special version for 25MHz, see below.
UPDATE: setting extended speed works now in ATTiny2313 firmware version (the trouble was with parameters endianness), so there's no need for special 25MHz version, but there can still be the point in using it - see notes below.

AT90S2313

Here is the patch to be applied to original source code. Compiled files for various crystals:

ATTiny2313

Here is the patch to be applied to original source code. Firmware for 14.7456MHz crystal works with any target frequency (up to twice the PODEX crystal), not only 25MHz, as the version for AT90S2313. But there's still the point in using 25MHz dedicated version - when using PODEX with 25MHz target and PC software that doesn't support setting extended speed (for example NoICE debugger), then this special firmware for 25MHz target lets pretend it's 16MHz target. In such a case, use the firmware for AT90S2313 (above). When using PODEX with hc12mem loader, there's no need to pretend anything and setting extended speed works fine, with any target frequency - so you can use the following firmware.

If you want to compile your own version, you need GNU GCC for AVR. Please refer to Marek's www page for details.

Build PODEX

This is simple. Solder the board, preferrably putting ICs in sockets. When done, connect 5V from external power supply directly to the board. Check for excessive current draw, shouldn't be more then few mA. Connect programming cable to the board and to the PC's printer parallel port. PODEX still needs external 5V supply for this, don't disconnect it (later on, PODEX gets the power from target board via BDM connector and doesn't need separate power supply).

For programming, there are two tools available: avrdude or uisp. Both are available as free software somewhere on the net (google is your friend). Command for programming is (substitute podex.hex with proper HEX file name):

AT90S2313

For AT90S2313, uisp was used:

uisp -v=3 -dlpt=0x378 -dprog=dapa --erase --upload --verify if=podex.hex

ATTiny2313

For ATTiny2313 uisp didn't work (it looks like no more maintained), so the more current avrdude was used (fuse settings are very important here):

avrdude -v -c dapa -p t2313 -U flash:w:podex.hex -U lfuse:w:0xde:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

PODEX for 25MHz MC9S12NE64

AT90S2313

For usage with MC9S12NE64, I run PODEX with 14.7456MHz crystal. Firmware is somewhat modified: RS232 baud rate is set for standard 115200bps, but timing for BDM connection requires setting target speed to 16MHz (8MHz E-clock, which is half the oscillator frequency). That has nothing to do with real target frequency (which is 25MHz), it's only setting for internal PODEX timing. Good thing is that GDB currently allows only few settings for E-clock, 8MHz is one of them :) Proper way should be setting extended speed, but that didn't work, there is something wrong with Podex firmware here, I didn't manage to investigate it yet, and did quick and dirty solution making this copy of PODEX dedicated to 25MHz, when seting it for 16MHz.

ATTiny2313

Firmware for ATTiny2313 is modified to wotk with default 14.7456MHz and allows using any target frequency, but not all tools support setting any freqency. In such case, you can use the firmware for AT90S2313, dedicated for 25MHz target and pretending it's 16MHz target. Please read notes under firmware section above. Otherwise, use the firmware for ATTiny2313.

Power supply

This is somewhat tricky, because PODEX by default requires 5V and MC9S12NE64 is 3.3V. What to do ? First of all, disconnect Vcc wire from BDM connection ! Then just supply PODEX from external 5V power supply. Connecting 5V PODEX to 3.3V NE64 is safe, because NE64 BDM pin is 5V tolerant.

It's possible to run PODEX from 3.3V, thus eliminating the need for separate 5V supply. I don't know if AT90S2313 will work with 14.7456MHz @ 3.3V (datasheet says it's up to 4MHz at this voltage). ATTiny2313 is specified with 10MHz at 3.3V, so it's more likely to work overclocked at 3.3V. But I haven't tried that. You will also need to change MAX232 to MAX3232.

Software

Because PODEX is protocol compatible with Kevin Ross' BDM12 POD, it can work with all software that supports BDM12 POD. For example: