Source Code Files
Contents
USB08 Evaluation Board Designer Reference Manual
MOTOROLA Source Code Files 117
U08ADC.C
//===================== ======================== ======================= ========
// File: U08ADC.C
// Func: Software ADC f or USB08
// Ver.: 1.00
// Auth: (C)2000,2001 b y Oliver Thamm, MCT Elek tronikladen GbR
// http://hc08web .de/usb08
// Rem.: View/Edit this File with TAB-Size=4
//===================== ======================== ======================= ========
#include "hc08jb8.h"
#include "u08adc.h"
//--------------------- ------------------------ ----------------------- --------
void initSADC() {
// disable internal Pul l-Ups on PTE
POCR &= ~0x80;// disable PTE20P
}
//--------------------- ------------------------ ----------------------- --------
unsigned scaleSADC(unsigne d t1 , un signed t2) {
t1 >>= 4;
t2 <<= 4;
_asm("lda 5,sp");
_asm("psha");
_asm("pulh");
_asm("ldx 2,sp");
_asm("lda 6,sp");
_asm("div"); // A = H:A/X
_asm("clrx"); // 0:A = t2/t1
}
//--------------------- ------------------------ ----------------------- --------
int getSADC(char channel) {
unsigned t0, t1, t2;
unsigned char p;
unsigned volatile zz;
// convert channel # 1/2/3 to 0x01/0 x0 2/ 0x04
if(channel == 3) channel++;