ATD1 Channel 0-7 conversion not happening with MC9S12XDP512MAG

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

ATD1 Channel 0-7 conversion not happening with MC9S12XDP512MAG

Jump to solution
563 Views
santhoshsl
Contributor III

Hello

 

We are using MC9S12XDP512MAG MCU for our development.

Currently we are using ADC10,11,12 in our project and for this we have following Control register values

    ATD1CTL0 = 0x0f;  // wrap around to AN0 after conv AN15

    ATD1CTL2 = 0x80;  // no interrupt, normal ATD functionality in power down mode

    ATD1CTL3 = 0x22;//0x1A;  // 4 conversions per sequence                              

    ATD1CTL4 = 0x47;  // 0x5f;  // bus clock divide by 16,           

    ATD1CTL5 = 0xB2;  // sample across several channels, unsigned and right justified, select channel 10 as Starting channel for seq 4 conversion

 

All other control register details were correct except for the ATD1CTL5. For which according to Data sheet, "BA" should be the value if you want a Multi channel (Seq 4) conversion with "A = An10" as a starting channel for conversion. But if you see the value i am using, it is B2. After doing manually checking the conversion data for each channel, i got this value. Writing which will make starting channel of conversion sequence as An10.

 

And now we want to move from this MCU to a 80 pin MCU MC9S12XDG128MAA and this doesnot have ADC's from An8 to An15. So wanted to use ADC1-3.

But when i am trying to get the ATD1CTL5 value for making An1/An0 channel as starting channel for conversion, i am seeing that what ever value I give in the lower nibble of ATD1CTL5, I am not seeing data read from ADC channels 0-7.

 

I just tried following chunk of code to read converted values from each ADC channel and did single step but couldnot read any of the ADC channels from An0-7.

 

main() {

int i=0;

    ATD1CTL0 = 0x0f;  // wrap around to AN0 after conv AN15

    ATD1CTL2 = 0x80;  // no interrupt, normal ATD functionality in power down mode

    ATD1CTL3 = 0x22;//0x1A;  // 4 conversions per sequence                              

    ATD1CTL4 = 0x47;  // 0x5f;  // bus clock divide by 16,           

    for (i=0;i<15;i++)

    {

         ATD1CTL5 = 0xA0 | i ;

    }

}

 

Some one help me in getting this issue resolved.

 

Also please let me know if the Documentation for ATD1CTL5 register is wrong in Data Sheet.

 

 

Labels (1)
Tags (2)
0 Kudos
1 Solution
422 Views
RadekS
NXP Employee
NXP Employee

1. MC9S12XDP512 has two ATD modules. ATD0 has 8 channels and module is routed to PAD00..PAD07. ATD1 has 16 channels and module is routed to PAD07..PAD23. Therefore you have to set channel 2 for PAD10

2. MC9S12XDG128 has just ATD1 module and this module is routed to PAD00..PAD07.

3. You don’t use fast flag clear feature, therefore you should clear flag manually.

4. Any write to ATDCTL5 register stops current conversion and starts new conversion. I would like to recommend add into loop something like this: while(ATD1STAT0_SCF == 0); //wait for end of conversion. There also missing any reading of measured data.

5.Continuous mode in this case looks useless.


View solution in original post

0 Kudos
2 Replies
423 Views
RadekS
NXP Employee
NXP Employee

1. MC9S12XDP512 has two ATD modules. ATD0 has 8 channels and module is routed to PAD00..PAD07. ATD1 has 16 channels and module is routed to PAD07..PAD23. Therefore you have to set channel 2 for PAD10

2. MC9S12XDG128 has just ATD1 module and this module is routed to PAD00..PAD07.

3. You don’t use fast flag clear feature, therefore you should clear flag manually.

4. Any write to ATDCTL5 register stops current conversion and starts new conversion. I would like to recommend add into loop something like this: while(ATD1STAT0_SCF == 0); //wait for end of conversion. There also missing any reading of measured data.

5.Continuous mode in this case looks useless.


0 Kudos
422 Views
santhoshsl
Contributor III

Hello Radek,

Thanks for your inputs. I tried configurations on ADC0 and was able to read values from ADC Ch0-7.

But this sort of information is not mentioned in data sheet.

Also thanks for you suggestion on using SCF flag before reading the conversion values.

0 Kudos