interrupt function with an A/D converter of a S12

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

interrupt function with an A/D converter of a S12

ソリューションへジャンプ
3,510件の閲覧回数
Delphine
Contributor I
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.
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
910件の閲覧回数
Blackwolf
Contributor III

Hello Delphine,

humm well... This issue may require some further investigations, but as starting line I would recommend you to check the following points:

1.) In the *.map file generated in the.\bin\ subfolder of your application, check that the interrupt routine is correctly placed in none banked memory

2.) in the *.map file check out the 'UNUSED_OBJECT' section and make sure that none of your variables/procedures were optimized

3.) I would recommend you to enable the interrupts 'after' the init routine...

On the other hand I would invite you to use Processor expert, the graphical code generator of Codewarrior to create an A/D driver as code sample.

hope this helps :smileywink:

Blackwolf

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
911件の閲覧回数
Blackwolf
Contributor III

Hello Delphine,

humm well... This issue may require some further investigations, but as starting line I would recommend you to check the following points:

1.) In the *.map file generated in the.\bin\ subfolder of your application, check that the interrupt routine is correctly placed in none banked memory

2.) in the *.map file check out the 'UNUSED_OBJECT' section and make sure that none of your variables/procedures were optimized

3.) I would recommend you to enable the interrupts 'after' the init routine...

On the other hand I would invite you to use Processor expert, the graphical code generator of Codewarrior to create an A/D driver as code sample.

hope this helps :smileywink:

Blackwolf

0 件の賞賛
返信
910件の閲覧回数
Delphine
Contributor I
Thank you for your help...
 
In fact, the problem was that there was a mistake into the datasheet of the M9S12DP256B, concerning the functioning principle of the flag (ATD0STAT_SCF)used for an A/D conversion...
 
It 's incredible, isn't it?
 
Delphine.
0 件の賞賛
返信
910件の閲覧回数
petr
Contributor I
Hello
I would say that it is not exactly mistake in the datasheet, but a hardware bug. Check errata of this cpu.
Regards
Petr
0 件の賞賛
返信