Reading the Hummer ADC: ADCRD

ADCRD is a ML routine for reading the Hummer analog-to-digital converter.

Unlike the C64DTV, the Hummer has a pot-driven ADC (the original c-64 had two paddle ports.) The ADC is an SNAD01C clone, a serial 8-bit ADC with 8 input channels. Only one channel is accessable on the Hummer, unfortunately.

Original threads on DTVhacking forum-- here and here

An in-depth description of the routine is here.

MISC INFO:

  • The ADC channel # is 0.
  • The ADC samples the full voltage range of +3.3v - 0v (Vcc to Gnd.)
  • The Hummer POT is a 100K linear pot with a rotational range of 270 degrees, but only 180 degrees of it's range changes the resistance values.
  • An INIT routine is necessary for some Hummer units.
  • Assembler used was C64ASM v1.1a, a freeware cross-assembler. First time I've used it, worked fine. I'm not stuck on it, though, and this could change.
  • There are two supported variations: Standard: ADCRDxx and Zeropage: ADCRDxxZ


ADCRD

Current version: v0.5
ADCRD05.ASM The source file
ADCRD05.PRG The assembled target program

Changes in the new version:

  • Return Value has been moved from zeropage:
    • $CE09 (52745): get (PEEK) the value of the ADC
  • The 9th bit which was not shown in all the SNAD01C datasheets, has been ignored. The extra clock tick for clearing it has been commented-out, and will be removed entirely in the near future.
  • When the INIT routine was added, a bug creeped when some of the code was changed to subroutines. An extra 1/2 clock cycle was overlooked. This 1/2 cycle, which was after the read, didn't effect the routine's operation. It's been removed.
  • These last two changes have eliminated 1.5 clock cycles from a READ.
  • IMPORTANT NOTE: there has been a performance hit resulting from the zeropage change. But it's not what you might expect--it seems to be a BASIC issue. Calling PEEK(52745) instead of PEEK(251) slows the basic loop down by about 10%. Because of this fact, the zeropage version will continue to be updated, along with the zeropage-free. If no conflicts exist with zpage address $FB, I recommend the zpage version.

USE:

  • Load the code: LOAD"ADCRDxx.PRG",8,1 (where xx is version #)
  • INIT the ADC: SYS52739 or JSR $CE03
  • Call the READ routine: SYS52736 or JSR $CE00
  • Get the ADC value: X = PEEK(52745) or LDA $CE09, etc.

Minimal BASIC example:

10 SYS52739
20 SYS52736
30 PRINT PEEK(52745);
40 GOTO20


ADCRDxxZ -- Zeropage versions

Version: v0.5Z zeropage version updated--instructions below apply to this version This also has additional changes outlined above, excluding the return value change.
ADCRD05Z.ASM The source file
ADCRD05Z.PRG The assembled target program

NOTE: there are significant changes in the new version:

  • Load addr is now $CE00 (52736), not $C000. Too many good ML programs already use $C000. And since the source is available, you can always reassemble for a custom addr.
  • Initialization routine added
    • There appear to be differences even among Hummers with the same REV #. It has never been neccesary to init my own, but others need initialization. The differences may lie in the ADC itself.
  • A jump table's been added at the start, so subroutine entries won't change in the future
    • $CE00 (52736): READ the ADC
    • $CE03 (52739): INIT the ADC
    • $CE06 (52742): Unused entry, just duplicates the READ jump (see David Murray's additions)
  • Return Value:
    • $FB (251): get (PEEK) the value of the ADC
  • All the delay loops have been removed
  • Several settings are loaded from RAM, rather than defined as constants. Again, this is just to make future use with other ADCs a little easier. And for debugging from BASIC. These variables are documented in the source.

USE:

  • Load the code: LOAD"ADCRDxx.PRG",8,1 (where xx is version #)
  • INIT the ADC: SYS52739
  • Call the READ routine: SYS52736 or JSR $CE00
  • Get the ADC value: X = PEEK(251) or LDA $FB, etc.

Minimal BASIC example:

10 SYS52739
20 SYS52736
30 PRINT PEEK(251);
40 GOTO20


ML Demo

David Murray wrote an addition, an ML routine which outputs the POT values without needing to enter the BASIC code. This is a great shortcut for those wishing to debug any new hardware connected to the ADC. It also makes a good demo of the ADC.

David's definitive webpages on the Hummer are Here.

I've included David's code in the following versions. (OK, this isn't the latest version of ADCRD, but it still works fine and you can update it yourself...)

ADCRD04B.ASM The source file, with David's code
ADCRD04B.PRG The assembled target program

USE:

  • The display routine can be entered using the third jump table entry:
    • SYS52742 ($CE06)
  • Pressing any key will exit back to BASIC
Otherwise, it functions the same as the regular code, with the first two entries in the jump table READ and INIT.

Home

DTV Links

This document looks WAY better in Firefox than some other browsers...