Have a look as well on http://e-www.motorola.com/index.html there are a lot of application notes with code around ADS/SPI/etc as well. Erich > -----Original Message----- > From: hellfire1272000 [mailto:] > Sent: Thursday, September 12, 2002 10:19 AM > To: > Subject: [68HC12] Re: ADC HCS12 DP256 > Thanks for the help Bob, can you explain to me why line > (ATDCTL5=0x70; //continuous scan, multichannel, 8 ch) has to be put > in the setup section as well as the conversion section? > > Please excuse me as I am a hardware engineer who is trying to get to > grips with this even though my "C" code ability is basic. > My company have just bought metrowerks for HCS12, it has been thrown > on my desk and I have been told to get to grips with it!!!! difficult > as the 2000 package only comes with a flashing LED program and a CD > Rom with 5000 pages of PDF files!, none of which actually contains > any useful "C" software routines ( accessing ADC, SPI, CAN,I/O > Frequency/Pulse counting)....help!! > > I am trying to write a series of routines that tests the basic > functionality of a custom made Analogue board with ADC, programmable > gain amplifiers, programmable offset all accessed by SPI. > --- In 68HC12@y..., BobGardner@a... wrote: > > In a message dated 9/10/02 10:00:57 AM Eastern Daylight Time, > > toby.merridan@s... writes: > > > > > > > I would like some help in putting together some C Code to set-up > and > > > read one ADC Channel continuously and also set-up and Scan > through > > > multiple ADC channels continuously. > > > > Example for icc12 and hc12a4.... hope its similar....... > > > > somewhere in a setup subroutine: > > ATDCTL2=0xc0; //atd enab > > ATDCTL4=0x07; //sample rate > > ATDCTL5=0x70; //continuous scan, multichannel, 8 ch > > > > and later in the program: > > //-------------------- > > void readads(void){ > > //read 8 ch of internal a/d into addat[] > > unsigned char i; > > unsigned int tmp; > > unsigned char bh,bl; > > volatile unsigned char *p; > > > > ATDCTL5=0x70; //init multichannel conv > > while((ATDSTAT & 0x80)==0){}; //wait for sequence finished > > p=&ADR0H; //point to ch 0 > > for(i=0; i < 8; i++){ > > bl=*p++; //lo byte > > bh=*p++; //hi byte > > tmp=((unsigned int)bh << 8) | bl; //form word > > addat[i]=tmp & 0x3ff; //save 10 bit value > > } > > } > > > > //-------------------- > > void showads(void){ > > //show 8 ch of internal a/d > > unsigned char i; > > > > printf("\n"); > > for(i=0; i<8; i++){ > > printf("%3d ",i); > > } > > printf("\n"); > > while(!kbhit()){ > > readads(); > > for(i=0; i < 8; i++){ > > printf("%04x ",addat[i]); > > } > > printf("\r"); > > } > > printf("\n"); > > } > > > > > > > > > > > -------------------- > > ">http://docs.yahoo.com/info/terms/ |