9s12xs ATD setup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

9s12xs ATD setup

Jump to solution
1,375 Views
roberthaines
Contributor II

Thanks in advance for answering what appears to be a basic question:

 

I've had some difficulty setting the ATD pins on my 9s12xs128.  My goal is to get all 16 pins set to A/D each to read a separate input.  However, after spending days changing one setting at a time, I'm starting to wonder if the chip is bad.  So, before I throw this one in the trash, please someone check my settings.

 

Here's the code (all other ATD settings are at their default):

 

ATD0CTL1_SMP_DIS  = 0;   // Discharge the pin prior to a reading

ATD0CTL1_SRES1    = 1;   // Sets to 12-bit resolution (default is 10-bit)
ATD0CTL1_SRES0    = 0;
ATD0CTL2_AFFC     = 1;   // Sets to Fast Flag Clear
ATD0CTL3_DJM      = 1;   // Right Justified
ATD0CTL3_S8C      = 0;   // 1 Conversion per sequence
ATD0CTL3_S4C      = 0;
ATD0CTL3_S2C      = 0;
ATD0CTL3_S1C      = 1;
ATD0CTL4_SMP2     = 1;   // 24 Clock cycles per scan
ATD0CTL4_SMP1     = 1;         
ATD0CTL4_SMP0     = 1;
ATD0CTL4_PRS      = 1;   // ATDCLK = 20mHz / (2 x (1+1)) = 5mHz [buss is at 20mHz]
ATD0CTL5_SCAN     = 1;   // Continuously scan
ATD0CTL5_MULT     = 1;   // Scan all channels

 

Now, when I put a few volts on any of the pins I get no readings.

 

I've also changed it to 16 conversions per sequence and tested pin ATD0 (I would expect it to read that pin 16 times) and what I get is registers ATD0DR0 through ATD0DR5 at 0000, ATD0DR6 and ATD0DR7 with a value that I can change switching the input voltage on and off (and the values do not match the voltage ratio), and ATD0DR8 through ATD0DR15 at 4095.  This at least lets me know that physically have it connected, but the results are confusing.

 

Also, if anyone has a simple C program I could load in CodeWarrior just to setup and test the ATD system, I would be happy to try it.

 

Please help and Thanks!

 

Robert

 

Adapt9s12sx breakout board from Technological Arts.

CodeWarrior 5.9.0

Connected by USB through a USBDM / TBDML

Labels (1)
0 Kudos
Reply
1 Solution
1,009 Views
roberthaines
Contributor II

SOLVED.

It was a minor wiring error.  I found an open in the circuit that provided power to Vrh of the ATD.  I had checked voltage but probed upstream of this open.  Rewired, system works fine, I screamed for a few minutes, and back to work!

Radek, thanks for your help.

And now we know what odd results you get when you do not power the ATD system properly.

Robert

View solution in original post

0 Kudos
Reply
5 Replies
1,010 Views
roberthaines
Contributor II

SOLVED.

It was a minor wiring error.  I found an open in the circuit that provided power to Vrh of the ATD.  I had checked voltage but probed upstream of this open.  Rewired, system works fine, I screamed for a few minutes, and back to work!

Radek, thanks for your help.

And now we know what odd results you get when you do not power the ATD system properly.

Robert

0 Kudos
Reply
1,009 Views
RadekS
NXP Employee
NXP Employee

In attachmen you can find simple example code for ATD module in multichannel mode. Note: example code was created for S12XEP100, but ATD module is the same as for S12XS and therefore code should be fully compatible.

Few notes:

You settings refers to continously scan of ATD channel 0. 

Any write to ATD0CTL5 starts new conversion.

If FIFO=0, results of sequence always starts from ATD0DR0 register (even if we measure for example channel 8).

ATD module could be configure for two types of sequences: one sample at multiple channels or multiple samples at one channel. Unfortunately combination is not possible.

If you will need any diffrent ATD example code (like interrupt, external trigger,...), please let me know.


1,009 Views
roberthaines
Contributor II

Radek,

Thanks for the reply and the code, but the 9s12 is still not working.  Here's what I did...

  1. I opened CodeWarrior, started a new project for my 9s12 version, copied the Main code from the example into the new Main, and sent it to the chip:  I got no response from ATD0 pin (I don't have any of the other pins connected).
  2. I modified the code from 8 to all 16 pins by simply adding additional variables and changing from 8 to 16 conversions:  I got similar response described in my first post (the first six registers are empty, seven and eight show a change, the last eight registers show maximum value).
  3. I changed the clock speeds for a 1 MHz ATD clock:  no change.

Unless the behavior detailed above describes a commonly incorrect setting, I'm considering that the ATD system on chip is simply not functional.

Robert

0 Kudos
Reply
1,009 Views
RadekS
NXP Employee
NXP Employee

Unfortunately I don’t have any idea what could be wrong.

I suppose that you using internal 4MHz crystal. In that case bus clock (without PLL) is 2MHz. ATD0CTL4_PRS should be set to 0x00 for 1MHz ATD clock.

Could you please describe source of your voltage? It is just simply voltage source (like 2.5V), or some potentiometer?

Unconnected PAD pins could results any value, but typically result is 0x00 (there depends on leakage current,…).

From AD9S12XS schematic - AN0 is routed to pin 22 at H1 primary I/O connector.

ATD0DR0L register is at address 0x02D1.


1,009 Views
roberthaines
Contributor II

Radek,

I've tried different speeds of the ATD clock, but all within the range detailed on the specification sheet.  This made no difference.

I've got the pin routed properly and am looking at all of the memory addresses for the ATD registers.  This is why the results are confusing.  It would appear that there is something wrong with the Mode and Timing Control or the Successive Approximation Register of the ATD system.  Of course I'm just guessing based on the odd results.

The voltage source has been a 1.5 volt battery or a combination to provide up to 4.5 volts.  No change in the odd results.  I do notice some flicker on open pins, usually just above 0x00.  This is not the problem I'm seeing.  And speaking of voltage, I do have the Vrh and Vrl connected to +5 and ground.

Again, the chip appears to be the problem, not the settings.

Thanks for your help,

Robert

0 Kudos
Reply