U08Adc.c - Motorola USB08 Reference Manual

Universal serial bus evaluation board using the mc68hc908jb8
Table of Contents

Advertisement

U08ADC.C

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

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mc68hc908jb8

Table of Contents