Scanning Multiple ATD channels with the MC9S12XDP512

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Scanning Multiple ATD channels with the MC9S12XDP512

1,103 次查看
KH_SRNL
Contributor I

I'm unable to successfully configure the MC9S12XDP512 for a multiple channel ATD acquisition.  I can scan individual channels and get correct results, but when configured for multiple mode, the results are garbage.  I've used the same code base on the MC9S12C132 chip (for ATD0) and it works correctly (for multiple channel scans).  Is there something specific about the MC9S12X that I'm not catching?  My register settings are as follows:

 

ATD0CTL2 = 0x80     //normal ATD operation with no fast clear and no external trigger

ATD0CTL3 = 0x40;     //8 conversions per sequence, conversions placed in corresponding registers

ATD0CTL4 = 0x05;     //10 bit resolution, 2 A/D clock periods per conversion, divide by 12; (8HMz bus clock)

ATD0CTL1 = 0x00;     //should not matter, no external trigger used

ATD0CTL0 = 0x01;     //wrap set to AN1; but should not be needed

ATD0CTL5 = 0x90;     //right justified data, multi-channel conversion, start on AN0

 

The ATD0STAT0 & ATD0STAT1 registers show acquisition complete on all channels.  I typically read 0x03 when I should be reading 0x2000.

标签 (1)
0 项奖励
回复
5 回复数

692 次查看
KH_SRNL
Contributor I

Actually I did check the pin on the processor.  I've made that mistake as well and the board is a custom build, so solder joints are always a concern.  I can read the individual channels in single channel mode (ATD0CTL5 = 0x8X where X represents the channel of interest).  I have a routine where I call my channels of interest (via the SCI port), read and report results.  I can read all channels as long as I do them individually (multiple conversion bit not set in control register 5).

What I want to do is measure all 8 channels of ATD0  with results stored in corresponding registers.  My PLL is active (8 MHz bus clock, 16 MHz system clock).  I'm running 10 bit resolution, right justified.  I don't want continuous scanning, just a single pass of all 8 channels with internal triggering (Scan - single, multiple channels).  I don't need an interrupt.  I just want to start the conversion and come back latter to grab the results.

Thanks

Kevin

0 项奖励
回复

692 次查看
lama
NXP TechSupport
NXP TechSupport

Hi, I am sorry for delay. I was not connected - vacation. Have you solved the issue or you still need a help?

0 项奖励
回复

692 次查看
lama
NXP TechSupport
NXP TechSupport

... a few examples ....see attachment.....

0 项奖励
回复

692 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

probably I am missing something but could you please confirm you want to measure channel 0 for 8 times with atdclk = 1.33Mhz, without interrupt.

BTW, have you checked the pin you measure is the right one and all ATD sources and references are OK. (not a joke. It is own experience). Then try to measure simple channel only in the loop to check everything is OK.

... or describe what you want to measure and I will prepare something.....

Best regards,

Ladislav

0 项奖励
回复

692 次查看
KH_SRNL
Contributor I

I obviously missed something in the register setup.  I thought ATD0CTL5 = 0x90 would start at channel 0 and scan 8 channels with the results placed in the corresponding registers.  The results will be right justified (10 bit conversion per settings in ATD0CTL4). 

Looking at your example code for a multichan conversion, ATD0CTL5 is set to 0x11.  It appears we both have the same bit selected for a multichan conversion (0x10).

Can you please clarify what I'm missing?  You stated my register settings will do 8 conversions on chan 0 and I don't understand.  Based on the ATD0CTL5 settings, it appears my code will do conversions on 8 different channels (0 through 7).

Regards,

Kevin

0 项奖励
回复