AnsweredAssumed Answered

interrupt function with an A/D converter of a S12

Question asked by b00451 b00451 Employee on Mar 30, 2006
Latest reply on Apr 6, 2006 by Petr Cach
Hello,
 
I am working on the configuration of the ATD0 of the M9S12DP256B and my problem is that I can't go through the interrupt function.
 
My program is described below:
 
#include <hidef.h>           /* common defines and macros */
#include <mc9s12dp256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
//Le résultat de la conversion est mis dans la variable ATD0DR0
//Accessible en lecture uniquement donc on recupere sa valeur
//Resultat sur 16 bits
int V_16bits = 0x0000; 
 
 
//Initialisation des registres du convertisseur Analogique-Numerique
void Init_CAN() { 
   
 /*ATDCTL0 et ATDCTL1 sont reserves*/
 
 /*initialisation de ATDCTL2*/
 ATD0CTL2 = 0x82; 
 
 /*initialisation de ATDCTL3*/
 ATD0CTL3 = 0x08;   
 
 /*initialisation de ATDCTL4*/
 ATD0CTL4 = 0x00;   
 
 /*l'ecriture dans le registre ATDCTL5 commence la conversion*/
  ATD0CTL5 = 0x80;
 
}
  
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
     
void main(void) {
 /* put your own code here */
 
 EnableInterrupts;
 
 Init_CAN();
  
  for(;:smileywink: { } /* wait forever */
 
}
 
//---------------------------------------------------------------------
//---------------------------------------------------------------------
 
//gestion de l'interruption de fin de capture du signal a convertir
#ifndef __SMALL__
#pragma CODE_SEG __NEAR_SEG NON_BANKED
#endif
 
interrupt 22 void interrupt_CAN() {    
    V_16bits = ATD0DR0;             
    ATD0STAT0_SCF = 1;  //conversion sequence has completed
 }
 
//---------------------------------------------------------------------
//---------------------------------------------------------------------
 
This program converts very well the analog voltage put in input.  
Could somebody help me to explain what is wrong in this problem to let me continue my project?
 
Thank you,
 
Delphine.
 

Outcomes