Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | D60A ECLK output

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

ADC HCS12 DP256 - hellfire1272000 - Sep 10 8:58:00 2002

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. I have Codewarrior for HCS12.Some
help would be appreciated as I am a newcommer to embedded.





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: ADC HCS12 DP256 - Author Unknown - Sep 10 12:00:00 2002

In a message dated 9/10/02 10:00:57 AM Eastern Daylight Time,
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");
}

[Non-text portions of this message have been removed]





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: ADC HCS12 DP256 - hellfire1272000 - Sep 12 3:19:00 2002

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");
> } >
>
> [Non-text portions of this message have been removed]





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Re: ADC HCS12 DP256 - Author Unknown - Sep 12 5:36:00 2002

In a message dated 9/12/02 4:20:45 AM Eastern Daylight Time,
writes: > 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? That's proabably redundant. Very observant. Original idea was to have all 8
channels continuously convert.... had some prob with that, so I fell back to
the version where I initiate conversion.... good luck with metroworks... this
list is full of guys looking for docs and tutorials on metroworks... a few of
them have conquereed it... I think they are renting themselves out as
consultants now... I like the imagecraft compiler... its inexpensive and the
guy that wrote it will actually answer your questions if you have any... [Non-text portions of this message have been removed]




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

RE: Re: ADC HCS12 DP256 - Erich Styger - Sep 12 6:58:00 2002

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");
> > }
> >
> >
> >
> >
> > [Non-text portions of this message have been removed] >
> --------------------------------------------------------
> To unsubscribe from this group, send an email to: > To learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

D60A ECLK output - Stephen Mac Neil - Sep 12 8:50:00 2002

Hello all

I am trying to hook up my logic analyzer to a debug port in my project, I
want to use my eclk as my external clock for my logic analyzer. I have one
problem I cannot get a clock signal off my elck (PE4). Any idea what's going
on? I am using a external crystal 16Mhz so I should see 8Mhz on the ECLK
right? One more thing I measured the Clock signal into the D60A and it is
16Mhz but the amplitude is only 400mV seems small to me but the processor is
working ok, is that small an amplitude ok?
Stephen [Non-text portions of this message have been removed]





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: D60A ECLK output - Ed Carryer - Sep 12 9:05:00 2002

Stephen,
Are you running in single chip mode?
If so, then the E clock defaults to a port pin function. You need to clear the NECLK bit in the PEAR register to enable the external E clock.

ed
--
At 10:50 AM 9/12/2002 -0300, you wrote:
>Hello all
>
>I am trying to hook up my logic analyzer to a debug port in my project, I
>want to use my eclk as my external clock for my logic analyzer. I have one
>problem I cannot get a clock signal off my elck (PE4). Any idea what's going
>on? I am using a external crystal 16Mhz so I should see 8Mhz on the ECLK
>right? One more thing I measured the Clock signal into the D60A and it is
>16Mhz but the amplitude is only 400mV seems small to me but the processor is
>working ok, is that small an amplitude ok? >
>Stephen >[Non-text portions of this message have been removed] >
>--------------------------------------------------------
>To unsubscribe from this group, send an email to: >To learn more about Motorola Microcontrollers, please visit
>http://www.motorola.com/mcu




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: D60A ECLK output - kp_venu - Sep 12 9:30:00 2002

Hi Stephen,
You should write to PEAR and MODE register for enabling the ECLK
output.
Regards,
Venu
// PEAR = 0x0; // to enable ECLK output for test purpose
// MODE = 0x80; // to enable ECLK output for test purpose
--- In 68HC12@y..., "Stephen Mac Neil" <macneil@d...> wrote:
> Hello all
>
> I am trying to hook up my logic analyzer to a debug port in my
project, I
> want to use my eclk as my external clock for my logic analyzer. I
have one
> problem I cannot get a clock signal off my elck (PE4). Any idea
what's going
> on? I am using a external crystal 16Mhz so I should see 8Mhz on the
ECLK
> right? One more thing I measured the Clock signal into the D60A and
it is
> 16Mhz but the amplitude is only 400mV seems small to me but the
processor is
> working ok, is that small an amplitude ok? >
> Stephen > [Non-text portions of this message have been removed]




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: D60A ECLK output - Adam Wofford - Sep 12 12:39:00 2002

Motorola made it a little tricky to figure out how to get the clock
externally while in Normal single-chip mode. After a lot of reading, I was
able to get it working perfectly for my project. The best information is
from the Motorola Documentation, in the description of NECLK in the PEAR
register. As the others have told you, you must set both the PEAR and the
MODE very carefully to get ECLK on PE4 (and 'ECLK on PE7 if you want) in
single chip mode.

I have PEAR=$01, which enables ECLK and 'ECLK on PE4/PE7 respectively, and
MODE=$80, which keeps the chip in normal single mode while allowing a
free-running ECLK -- this specific setting for MODE is not described in the
documentation, the factory Normal Single Chip mode described in the docs.
does not allow a free-running ECLK.

From Docs;
===============================================
NECLK - No External E Clock
Normal single chip: write once; special single chip: write anytime; all
other modes: write never. Read anytime. In peripheral mode, E is an
input and in all other modes, E is an output.
0 = PE4 is the external E-clock pin subject to the following
limitation: In single-chip modes, to get an E clock output signal,
it is necessary to have ESTR = 0 in addition to NECLK = 0.
1 = PE4 is a general-purpose I/O pin.
=============================================== ----- Original Message -----
From: Stephen Mac Neil
To:
Sent: Thursday, September 12, 2002 9:50 AM
Subject: [68HC12] D60A ECLK output Hello all

I am trying to hook up my logic analyzer to a debug port in my project, I
want to use my eclk as my external clock for my logic analyzer. I have one
problem I cannot get a clock signal off my elck (PE4). Any idea what's going
on? I am using a external crystal 16Mhz so I should see 8Mhz on the ECLK
right? One more thing I measured the Clock signal into the D60A and it is
16Mhz but the amplitude is only 400mV seems small to me but the processor is
working ok, is that small an amplitude ok?
Stephen [Non-text portions of this message have been removed] Yahoo! Groups Sponsor
ADVERTISEMENT

--------------------------------------------------------
To unsubscribe from this group, send an email to: To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )