Count between two inpulsion

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

Count between two inpulsion

ソリューションへジャンプ
2,358件の閲覧回数
loulou
Contributor I
Hello Friend,
 
 
I work on the MC9S12XDP512EVB and I work whith code warrior 4.1.
 
Now I want to count a time between two inpulsions but a i have 2 or 3 small problem or/and questions.
 
First Question
is It  possible not to use an interruption to manage the flags?  Or rather the microcontrollor can make it of him same ?
 
Me i don't use the interruption.
 
My Program:
 
#define TCTL_3 (*((char*)0x004A))
#define TCTL_4 (*((char*)0x004B))
#define LECTURE (*((short int*)0x0050))
#define TEMPS (*((short int*)0x3000))
 
//////////////////////////////////////////////////////////////////////////////////////////// 
void main(void) {
 
init_timer();  
   
 for(;:smileywink: {

 if ( TFLG1_C0F ) {
   TEMPS=LECTURE;
      }
}
//////////////////////////////////////////////////////////////////////////////////////////// 
 static void init_timer(void)  {
  
  TEMPS=0x0034;
  TIOS = 0xFE;
   TIE =0x00;
  TSCR2 =0x06;
   TCTL_3=0x00;
  TCTL_4=0x01;
  TSCR1=0xE8;
  
 } 
////////////////////////////////////////////////////////////////////////////////////////////// 
My program makes first of all an initialization of the module timer and after i wait an inpulsion on IOS0.
 
But the problem the microcontrollor don't put the flags at 0 and me i can't it too.
this fact my count don't restart and i don't take a good count between two inpulsion.
 
Now I turn to you for your assitance. I looking for of information and assistance on this programmme so that it realise the operation which I wish.
 
But if you have a other similar program of this you can take me please.
 
thank you for your assistance
 
 
PS: I'm sorry for my bad english
 
 
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
627件の閲覧回数
Alban
Senior Contributor II
Salut Loulou !
 
Reading a value is not enough to clear a flag.
The general rule of thumb on S12 to clear a flag is:
- Read the register which has the flag set,
- Write a ONE to the bit you want to reset or to its associated ACK bit.
 
So, and I haven't looked at your example in particular, but:
You can check the flag sometimes (what you do with your IF) it is reading the register. But then, within the "if" you whould do something like
TFLG1_TOF = 1; or use an ACKnowledgment bit if exists.
 
Do you see what I mean ?
Alban.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
628件の閲覧回数
Alban
Senior Contributor II
Salut Loulou !
 
Reading a value is not enough to clear a flag.
The general rule of thumb on S12 to clear a flag is:
- Read the register which has the flag set,
- Write a ONE to the bit you want to reset or to its associated ACK bit.
 
So, and I haven't looked at your example in particular, but:
You can check the flag sometimes (what you do with your IF) it is reading the register. But then, within the "if" you whould do something like
TFLG1_TOF = 1; or use an ACKnowledgment bit if exists.
 
Do you see what I mean ?
Alban.
0 件の賞賛
返信
627件の閲覧回数
loulou
Contributor I
Thank you for your answer Alban.
 
 
I understood well what you said  for restart the flags but if i  restart the flags is what my count will pass by again has 0 too ??
 
Now I go to test the restart flag.
 
Thank
0 件の賞賛
返信