<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S12 / MagniV Microcontrollers中的主题 I am having difficulty with ATD on Dragon 12-plus</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153154#M4476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 1;"&gt;I am providing the code that I have so far.&amp;nbsp; Ignore the commented sections because I am not complete with it at the moment.&amp;nbsp; My goal here is to read from three ports, PAD01 - 03 with the input from an Accelerometer.&amp;nbsp; In the function for ATD0CTL5 register, I want to read in from each output of the accelerometer, X, Y, and Z which should give me values for each axis.&amp;nbsp; I am not sure if I wrote it in the code correctly though.&amp;nbsp; I believe I have it set up for only to read in for PAD02 but I am not sure the proper procedure to write it for three sequences of input.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 1;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 3;"&gt;&lt;SPAN style="font-size: 1;"&gt;// accelerometer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;#include &amp;lt;mc9s12dp256.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt; &lt;STRONG&gt;int&lt;/STRONG&gt; _textmode;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// globals&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt; &lt;STRONG&gt;char&lt;/STRONG&gt; dvalues[3];&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// array to hold digitized values from one sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// function prototype&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; init_ATD0(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; load_ADC0interrupt_addr(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;//load ADC Interrupt vector into vector table&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; convert(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; ADC0_handler(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; delayvar(&lt;STRONG&gt;int&lt;/STRONG&gt; multiplier);&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// main start here&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; main (&lt;STRONG&gt;void&lt;/STRONG&gt;){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// unsigned char x=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// unsigned char y=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*load_ADC0interrupt_addr( ); // load ADC Interrupt vector into vector table&lt;BR /&gt;init_ATD0( );&lt;BR /&gt;convert( ); // start conversion&lt;BR /&gt;delayvar(5);&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #000000; font-size: 1;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;(1){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*&lt;BR /&gt;if(lowVx &amp;lt; x-input &amp;gt; highVx)&lt;BR /&gt;// printf("Value x=%d\n\r",x-input);&lt;BR /&gt;// Send interrupt because tilt is out of range&lt;BR /&gt;&lt;BR /&gt;if(lowVy &amp;lt; y-input &amp;gt; highVy)&lt;BR /&gt;// printf("Value y=%d\n\r",y-input);&lt;BR /&gt;// Send interrupt because tilt is out of range&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End while&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End main&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; delayvar(&lt;STRONG&gt;int&lt;/STRONG&gt; multiplier){&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// a variable delay: multiplier = 125 is ~5 sec.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt; &lt;STRONG&gt;int&lt;/STRONG&gt; i,j,k;&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(i=0;i&amp;lt;multiplier;i++){&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(j=0;j&amp;lt;0xFF;j++){&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(k=0;k&amp;lt;0xFF;k++){&lt;BR /&gt;asm(&lt;EM&gt;"nop"&lt;/EM&gt;);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End delayvar&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; init_ATD0( ){&lt;BR /&gt;ATD0CTL2 = 0x82;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// turn on ADC unit 0, FFCA=1, ASCIE=1(enables ATD0 interrupt) 11000010&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;delayvar(3);&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// stabilize ADC unit electronics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;ATD0CTL3 = 0x18;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// 0001 1000 = 3 conversions/sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;ATD0CTL4 = 0x8B;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// 8-bit resolution, 2 A/D clk/conv., 1 MHz conv. frequency&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; convert(&lt;STRONG&gt;void&lt;/STRONG&gt;){&lt;BR /&gt;ATD0CTL5 = 0x32;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// left justify, unsigned, scan multi, Ch. 2&amp;amp;3, begin sampling, uses AN2-&amp;gt; PAD02&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #000000; font-size: 1;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;((ATD0STAT &amp;amp; 0X80) == 0){&lt;BR /&gt;}&lt;BR /&gt;dvalues[0] = ATD0DR0H;&lt;BR /&gt;dvalues[1] = ATD0DR1H;&lt;BR /&gt;dvalues[2] = ATD0DR2H;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*&lt;BR /&gt;void load_ADC0interrupt_addr( ){&lt;BR /&gt;asm("pshx");&lt;BR /&gt;asm("ldx #_ADC0_handler");&lt;BR /&gt;asm("stx $3e52"); // loads the isr for the ADC0_handler into the...&lt;BR /&gt;asm("pulx"); // ..pseudo-vector table&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#pragma interrupt_handler ADC0_handler( )&lt;BR /&gt;&lt;BR /&gt;void ADC0_handler(void){ //reads out results from ATD0DRx regs. and stores them&lt;BR /&gt;unsigned char *ptr = &amp;amp;dvalues[0]; //variable pointer to storage area 4 results&lt;BR /&gt;// puts("\nProgram Interrupted\n\r"); //comment out: causes delay &amp;amp; affects data&lt;BR /&gt;asm("sei"); // mask further interrupts until this service finishes&lt;BR /&gt;ptr[0] = ATD0DR0H;&lt;BR /&gt;ptr[1] = ATD0DR1H;&lt;BR /&gt;asm("cli"); // reenable interrupt in order get next sequence&lt;BR /&gt;}&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Nov 2009 01:02:01 GMT</pubDate>
    <dc:creator>skatingdisaster</dc:creator>
    <dc:date>2009-11-10T01:02:01Z</dc:date>
    <item>
      <title>I am having difficulty with ATD on Dragon 12-plus</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153154#M4476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 1;"&gt;I am providing the code that I have so far.&amp;nbsp; Ignore the commented sections because I am not complete with it at the moment.&amp;nbsp; My goal here is to read from three ports, PAD01 - 03 with the input from an Accelerometer.&amp;nbsp; In the function for ATD0CTL5 register, I want to read in from each output of the accelerometer, X, Y, and Z which should give me values for each axis.&amp;nbsp; I am not sure if I wrote it in the code correctly though.&amp;nbsp; I believe I have it set up for only to read in for PAD02 but I am not sure the proper procedure to write it for three sequences of input.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 1;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #008000; font-size: 3;"&gt;&lt;SPAN style="font-size: 1;"&gt;// accelerometer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;#include &amp;lt;mc9s12dp256.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt; &lt;STRONG&gt;int&lt;/STRONG&gt; _textmode;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// globals&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt; &lt;STRONG&gt;char&lt;/STRONG&gt; dvalues[3];&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// array to hold digitized values from one sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// function prototype&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; init_ATD0(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; load_ADC0interrupt_addr(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;//load ADC Interrupt vector into vector table&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; convert(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; ADC0_handler(&lt;STRONG&gt;void&lt;/STRONG&gt;);&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; delayvar(&lt;STRONG&gt;int&lt;/STRONG&gt; multiplier);&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// main start here&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; main (&lt;STRONG&gt;void&lt;/STRONG&gt;){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #008000;"&gt;// unsigned char x=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// unsigned char y=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*load_ADC0interrupt_addr( ); // load ADC Interrupt vector into vector table&lt;BR /&gt;init_ATD0( );&lt;BR /&gt;convert( ); // start conversion&lt;BR /&gt;delayvar(5);&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #000000; font-size: 1;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;(1){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*&lt;BR /&gt;if(lowVx &amp;lt; x-input &amp;gt; highVx)&lt;BR /&gt;// printf("Value x=%d\n\r",x-input);&lt;BR /&gt;// Send interrupt because tilt is out of range&lt;BR /&gt;&lt;BR /&gt;if(lowVy &amp;lt; y-input &amp;gt; highVy)&lt;BR /&gt;// printf("Value y=%d\n\r",y-input);&lt;BR /&gt;// Send interrupt because tilt is out of range&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End while&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End main&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style=": ; color: #008000;"&gt;// functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; delayvar(&lt;STRONG&gt;int&lt;/STRONG&gt; multiplier){&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// a variable delay: multiplier = 125 is ~5 sec.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt; &lt;STRONG&gt;int&lt;/STRONG&gt; i,j,k;&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(i=0;i&amp;lt;multiplier;i++){&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(j=0;j&amp;lt;0xFF;j++){&lt;BR /&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;(k=0;k&amp;lt;0xFF;k++){&lt;BR /&gt;asm(&lt;EM&gt;"nop"&lt;/EM&gt;);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// End delayvar&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; init_ATD0( ){&lt;BR /&gt;ATD0CTL2 = 0x82;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// turn on ADC unit 0, FFCA=1, ASCIE=1(enables ATD0 interrupt) 11000010&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;delayvar(3);&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// stabilize ADC unit electronics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;ATD0CTL3 = 0x18;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// 0001 1000 = 3 conversions/sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #000000;"&gt;ATD0CTL4 = 0x8B;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// 8-bit resolution, 2 A/D clk/conv., 1 MHz conv. frequency&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style="color: #000000;"&gt;}&lt;BR /&gt;&lt;STRONG&gt;void&lt;/STRONG&gt; convert(&lt;STRONG&gt;void&lt;/STRONG&gt;){&lt;BR /&gt;ATD0CTL5 = 0x32;&lt;/SPAN&gt; &lt;SPAN style=": ; color: #008000;"&gt;// left justify, unsigned, scan multi, Ch. 2&amp;amp;3, begin sampling, uses AN2-&amp;gt; PAD02&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style=": ; color: #000000; font-size: 1;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;((ATD0STAT &amp;amp; 0X80) == 0){&lt;BR /&gt;}&lt;BR /&gt;dvalues[0] = ATD0DR0H;&lt;BR /&gt;dvalues[1] = ATD0DR1H;&lt;BR /&gt;dvalues[2] = ATD0DR2H;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1;"&gt;&lt;SPAN style=": ; color: #008000;"&gt;/*&lt;BR /&gt;void load_ADC0interrupt_addr( ){&lt;BR /&gt;asm("pshx");&lt;BR /&gt;asm("ldx #_ADC0_handler");&lt;BR /&gt;asm("stx $3e52"); // loads the isr for the ADC0_handler into the...&lt;BR /&gt;asm("pulx"); // ..pseudo-vector table&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#pragma interrupt_handler ADC0_handler( )&lt;BR /&gt;&lt;BR /&gt;void ADC0_handler(void){ //reads out results from ATD0DRx regs. and stores them&lt;BR /&gt;unsigned char *ptr = &amp;amp;dvalues[0]; //variable pointer to storage area 4 results&lt;BR /&gt;// puts("\nProgram Interrupted\n\r"); //comment out: causes delay &amp;amp; affects data&lt;BR /&gt;asm("sei"); // mask further interrupts until this service finishes&lt;BR /&gt;ptr[0] = ATD0DR0H;&lt;BR /&gt;ptr[1] = ATD0DR1H;&lt;BR /&gt;asm("cli"); // reenable interrupt in order get next sequence&lt;BR /&gt;}&lt;BR /&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2009 01:02:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153154#M4476</guid>
      <dc:creator>skatingdisaster</dc:creator>
      <dc:date>2009-11-10T01:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: I am having difficulty with ATD on Dragon 12-plus</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153155#M4477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You have a fatal bug here:&lt;BR /&gt;&lt;BR /&gt;unsigned char dvalues[3];&lt;BR /&gt;&lt;BR /&gt;Since this is shared by the ISR, it must be volatile. This seems like a likely cause of the problem.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ATD0CTL2 = 0x82; // turn on ADC unit 0, FFCA=1, ASCIE=1(enables ATD0 interrupt) 11000010&lt;BR /&gt;&lt;BR /&gt;Despite your comment, you do not set the AFFC. This means you must clear the flag manually, which you don't seem to do anywhere in the ISR.&lt;BR /&gt;&lt;BR /&gt;As a parenthesis, I wonder if the delay between the write to ATD0CTL2 and ATD0CTL3 is necessary. Where did you read that?&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2009 20:21:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153155#M4477</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2009-11-10T20:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: I am having difficulty with ATD on Dragon 12-plus</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153156#M4478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So how should I change the dvalues array?&amp;nbsp; Should I make it larger?&lt;BR /&gt;I am still confused on how the conversions and sequences come into play.&amp;nbsp; What do the conversions in a sequence represent?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For the ATD0CTL2, I should have 0xC2 instead correct?&amp;nbsp; ( 1100 0010 ) so the flag is cleared.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the delay I saw in one of the older programs I had for a lab.&amp;nbsp; The comment it gave was&amp;nbsp; to stablize ADC unit electronics.&amp;nbsp; The delay function is from an older lab as well.&amp;nbsp; In the older programs I saw, they all used a 5us delay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also think I may have to use a nonFIFO mode.&amp;nbsp; I think when I do that, the data in the array will be reset once it completes a sequence.&amp;nbsp; So for ATD0CTL3 register, would I use 0xxxx000?&lt;/P&gt;&lt;P&gt;I am not&amp;nbsp;positive on&amp;nbsp;how to implement the conversions for sequence.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2009 23:29:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153156#M4478</guid>
      <dc:creator>skatingdisaster</dc:creator>
      <dc:date>2009-11-10T23:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: I am having difficulty with ATD on Dragon 12-plus</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153157#M4479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Declare it as&lt;BR /&gt;&lt;BR /&gt;volatile unsigned char dvalues[3];&lt;BR /&gt;&lt;BR /&gt;If you don't understand why, I'd strongly recommend to read a beginner book about embedded programming. Here is a good online one:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://users.ece.utexas.edu/~valvano/embed/toc1.htm" target="test_blank"&gt;http://users.ece.utexas.edu/~valvano/embed/toc1.htm&lt;/A&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2009 21:27:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153157#M4479</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2009-11-11T21:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: I am having difficulty with ATD on Dragon 12-plus</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153158#M4480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in order to get 3 ADC channel's result values, you have to turn the multiplexer to route the signal or potential to the correct internal channel. It that has to be done one step at a time for each of the channels used. What you show in your init routine seems to be writing the correct control bits. However, your convert routine needs to take a channel number and write to the control register to start the analog convertion sequence on 3 channels. ie in polled mode.&lt;/P&gt;&lt;P&gt;word result1,&amp;nbsp;result2, result3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;result1 Convert(channel 3);&amp;nbsp;&lt;/P&gt;&lt;P&gt;result2&amp;nbsp;Convert(channel 4);&lt;/P&gt;&lt;P&gt;result3&amp;nbsp;Convert(channel 5);&amp;nbsp;&lt;/P&gt;&lt;P&gt;result=result1+result2+result3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope, i understood what you were trying to do and came up with the correct explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2009 13:02:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I-am-having-difficulty-with-ATD-on-Dragon-12-plus/m-p/153158#M4480</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2009-11-16T13:02:38Z</dc:date>
    </item>
  </channel>
</rss>

