MC13213 ATD power supply pin

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

MC13213 ATD power supply pin

4,671 Views
kelvinNgai
Contributor I
Dear all,
I have worked on the ATD converter of MC13213 for days. It has no any response after I writes its registers according to the manual.
I have a question after reading the manual many times.
Which pin is Vssad. I cannot find it. It should be ATD ground supply voltage. But I cannot find which pin assigned to it.

Many thanks

Kelvin Ngai
Labels (1)
0 Kudos
12 Replies

844 Views
Brodek
Contributor II

I have the same problem as you!! The ATD conversion always give my only 250 (8bit) also if I tie the AD input to GND. The VDDAD and VREFH are short circuited and at VDD (3V) and PRS is set to support a max bus freq of 8MHz ( I've 4MHz for mt device ). I wait for that CCF value become 1 and only after i read ATD1RH.

 

Why I only see 250 ?? Also with BDM or sending this data with the radio to the demo NCB demo board to show the data on the LCD the value is 250.

 

Heeeeelp!!!

0 Kudos

844 Views
frusty
Contributor I
I've got equal problems. I cant get the ATD to give me some results. In debug mode he goes to the ATD interrupt subroutine but  I never get any values.

Code example:

void Init_PWM (void){
  /
  TPM2C2SC = 0x3C;            
  TPM2C2VH = 0x05;               
  TPM2C2VL = 0xD2;                
 
  TPM2MODH = 0x83;
  TPM2C2SC = 0x3C;
 
  TPM2SC = 0x48;
   


}

void Init_ATD (void){
  ATDPE = 0x01;     
  ATDC = 0xB1;
  ATDSC = 0x40;
}




 union DATA
{
   uint8_t Buffer[2];
   uint16_t digit;
} ATDdata;
 

__interrupt void ATD_ISR(void)
{
 
  /*ATDdata.Buffer[0] = ATDRH;
  ATDdata.Buffer[1] = ATDRL;*/
  TPM2C2VH = (ATDRH ^0x80);
  TPM2C2VL = ATDRL ;
  ATDSC = ATDSC;
}

0 Kudos

844 Views
kelvinNgai
Contributor I
Dear All,
Thank you very much for your reply. I have got some response from ATD. I did not use the BDM. When the CCF is toggled. i send the result of ATD to terminal.
Anyway, there are still some problems. The output is either 0 or higher than 250,say 252, 255 whatever the input of the ATD is.
whether it is 0 or 255 depends on the VrefH. I do not know why.
If the VrefH is higher than the Vdd, then its output is always above 250 and keep that value if i dont change the VrefH,
If the VrefH is lower than the Vdd, then its output is always 0.
It is independent to the input of ATD.

Any ideas

Many thanks!
Kelvin Ngai.
0 Kudos

844 Views
bigmac
Specialist III
Hello Kelvin,
 
In your earlier post you confirmed that VrefH was connected to Vdd - but it would appear now that this is not so.  The earlier post also indicated that you were set up for 10-bit conversions - I wonder if this remains so?
 
Since your serial output code to the terminal is not yet "proven", we can't yet rule out that some of your problems are not in this area.  Directly examining the raw ATD result (using BDM) may better reveal whether the ATD operation is problematic.  However, you will not be able to single step through the code (to prevent the flag clearing problems), but should set a breakpoint within your ATDconvert() ISR code.  You should then be able to observe the data register values directly, to see if these correlate with the serial output to the terminal.
 
Regards,
Mac
 
0 Kudos

844 Views
rocco
Senior Contributor II
Hi, Kelvin:

I believe that the ATD needs to have VrefH EQUAL to Vdd.

In the MC1321x Technical Data manual, section "6.3.3 MCU ATD Characteristics", the table indicates that VrefH should be equal to Vddad, and at the bottom of that section note 1 says "Vddad must be at same potential as Vdd".
0 Kudos

844 Views
kelvinNgai
Contributor I
Hi Rocco,

I think it is not due to the long interrupt routine. I use a very short one, it still does not work. I used the debug mode and use "run to cursor" to the interrupt, it never stop which means that the interrupt never be triggered.
Besides, I have no LED since the device is designed by myself. The only way is to use SCI serial terminal to show result.

Could anyone give me a work example code to show that the ATD works or not with internal busclock 4MHz.

Thank you very much.
0 Kudos

844 Views
kelvinNgai
Contributor I
Hello Mac,

Thank you very much! I have connected VrefH to Vdd supply and VrefL to Vss suply. And there is a bypass capacitor for VrefH.
From the MC1321xRM.pdf(p332. Figure 20-1), it states that the VssAD is chip pad. So I am confused.

I use Self-clocked Mode, so the busclk is 4MHz.
The code for ATD is:
void ATDInit(void) {
//UINT8 atdc;
//10 bits unsigned no prescler
ATD1C = 0x83; // /* ATD1 Control Register; 0x00000050 */
ATD1SC = 0x60; // /* ATD1 Status and Control Register; 0x00000051 */
ATD1PE = 0x01;
}
what i understand:
ATD1C = 0x83 //Enable the ATD and set the prescaler "0011" so according to Table 20-4 in MC1321xRM.pdf, ATD conversion rate is 500KHz

ATD1SC = 0x60 //interrupt enable with continue conversion mode. so the ATD convert at 500KHz continuously right? Channel used is AD0

ATD1PE = 0x01 //AD0 channel is enabled.

That is all I did to initialize the registers.
Then I have an interrupt routine

UINT8 ATDDataBuffer[2];
UINT32 digit;
char App_Str[10];
interrupt void ATDconvert() {

ATDDataBuffer[1] = ATD1RH;
ATDDataBuffer[0] = ATD1RL;;
digit = (UINT32) ATDDataBuffer[0];
digit 8;
digit += (UINT32) ATDDataBuffer[1];

(void)int2string(digit, App_Str);
SCITransmitStr("data have been read\n");
SCITransmitStr(App_Str);
}
I have register the interrupt in vector table: ATDconvert, /* vector 23: ATD */
Anything wrong?? I use debug mode, so I saw the CCF in ATD1SC register is always 0. so no conversion.

Thank you!
0 Kudos

844 Views
bigmac
Specialist III
Hello Kelvin,
 
The ATD initialisation seems OK.
 
Note that the CCF flag will be cleared with any read of the data registers - the problem may be with debug mode only, because you may be monitoring (reading) the data registers, so effectively clearing the CCF before you can observe it being set.  Do you actually reach the ISR code?
 
I agree with Rocco about your inappropriate ISR content.  With continuous conversion mode, and the 500kHz ATD clock, the total execution time for the ISR must be very considerably less than 224 bus cycles (56us).  Whether or not it is appropriate to operate with continuous conversions with depend on the the degree of processing of the data that you require.
 
I think there is also a typo error in one of the lines following the read of the data registers.  However, this processing seems to be a round about way of not achieving very much.  You appear to require that the "digit" variable (that I assume is global) contain the current reading, but I am not sure why you need a 32 bit value.  You could more simply and quickly directly load each reading byte to the variable, rather than do the calculations.  I would tend to use a union between a two-byte array and an unsigned integer.
 
union DATA
{
   UINT8 Buffer[2];
   UINT16 digit;
} ATDdata; 
 
interrupt void ATDconvert(void)
{
  ATDdata.Buffer[0] = ATD1RH;
  ATDdata.Buffer[1] = ATD1RL;
  ...
}
 
ATDdata.digit should then give a left justified, 16-bit value with the current settings.
 
Regards,
Mac
 
0 Kudos

844 Views
rocco
Senior Contributor II
Hi, Kelvin:

I'm not sure if this is your problem, but I noticed that your interrupt-service routine is too big.

If you want to convert at the ATD module's full speed, the ISR needs to be very lean. Trying to output those strings is going to take a lot longer than your conversions. I realize that they are just there for debugging, so maybe you can replace them with a quick toggle of an LED.
0 Kudos

844 Views
kelvinNgai
Contributor I
Hi Mac,

Thank you very much!

I have tried almost all possibilities.
This time, i use single conversion mode with interrupt.
ATD1PE = 0x02;
ATD1C = 0xA0;
ATD1SC = 0x41;


interrupt void ATDconvert(){
result = ATD1RH;
ATD1SC = ATD1SC;
}

but it still does not work.

how come ??/ so frustrated.
It is my Final Year Project.

Any other possible mistake ??
0 Kudos

844 Views
strikecity
Contributor I
I've been working on these identical issues. I've submitted an SR regarding the undocumented connection of VSSAD. But, since I have my ATD working, I can only assume that VSSAD is internally connected to VSS.

I think your CCF issue may be related to your use of the BDM. I had my local Freescale FAE looking over my shoulder, and we never saw the CCF flag get asserted. I wasn't using interrupts at all, I just had a routine polling the flag. We watched it over and over, and the flag was never set. Fortunately, I do have some LED's available for debugging, so I decided to disconnect the BDM cable, and just toggle an LED when the flag was set. Miraculously, this worked on the first try! When I reconnected the BDM, it again failed. My conclusion: the BDM executes read commands on ATD1RH and ATD1RL, thereby clearing the CCF flag before the internal software can see it. I also observed unexpected device operation when using the BDM in conjunction with sleep modes.

Score:
-----------------------
Bit togglers: 2
In-circuit debuggers: 0
0 Kudos

844 Views
bigmac
Specialist III
Hello Kelvin,
 
It would seem that VssAD is an internal connection for the MC13213.
 
Have you also connected VrefH to Vdd supply, and VrefL to Vss supply?  There should also be a separate bypass capacitor between the VrefH and VrefL pins.
 
If your problems persist, you might consider posting the code associated with your ATD operation.
 
Regards,
Mac
 
0 Kudos