Problem with #define in microcontroller header file

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

Problem with #define in microcontroller header file

ソリューションへジャンプ
3,333件の閲覧回数
matheus
Contributor I
Hi All!
 
   I have a problem with #defines in my application. It seems that my application don't recognizes mc9s08ac16.h #defines. My code seems like this:
 
 
#include "spihw.h"  //#include <mc9s08ac16.h> is in spihw.h
 
Hw_Init(){
 
UINT8 atualiza = 1;
 
do{
        if(atualiza)
        {
            atualiza = 0;
            ui16OldTime = TPM1CNT;
        }
 
        if( (TPM1CNT - ui16OldTime) > TPM1_1MS)
        {
            atualiza = 1;
            LED00 = !LED00;
        }
    }while(1);
}
 
When this code is running the ui16OldTime value is always zero and when I try watch TPM1CNT value data window shows a message: "undefined expression (unknown identifier)", but TPM1CNT is declared in mc9s08ac16.h.
 
  Someone know what is happening with my application?
 
  Thanks,
  Matheus.
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,787件の閲覧回数
allawtterb
Contributor IV
The actual variable behind TPM1CNT in the header is probably _TPM1CNT, try adding this to your watched expressions.  The debugger will not show the value of defines, these are only seen by the pre-processor.  TPM1CNT is replaced with whatever it is defined is, probably _TPM1CNT.Word.   

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,787件の閲覧回数
fabio
Contributor IV
Hello Matheus,

Did you initialize TPM1? Out of reset, TPM1SC = 0x00 meaning that the TPM clock source is disabled (the timer does not increment).

Regarding the TPM1CNT symbol, I agree with Allawtterb. The correct debugging symbol is _TPM1CNT.

Best regards,
0 件の賞賛
返信
1,787件の閲覧回数
matheus
Contributor I
  Hello Fabio!
 
  Yes I did. I was not using the _TPM1CNT debbuging symbol. When I used _TPM1CNT.Word instead of TPM1CNT I saw the correct value.
 
  Thanks for fast answer,
  Matheus.
0 件の賞賛
返信
1,788件の閲覧回数
allawtterb
Contributor IV
The actual variable behind TPM1CNT in the header is probably _TPM1CNT, try adding this to your watched expressions.  The debugger will not show the value of defines, these are only seen by the pre-processor.  TPM1CNT is replaced with whatever it is defined is, probably _TPM1CNT.Word.   
0 件の賞賛
返信
1,787件の閲覧回数
matheus
Contributor I
  Hello allawtterb!
 
  You are right. I used  _TPM1CNT.Word instead of TPM1CNT and the debugger showed me the correct value of PM1CNT.
 
  Thanks a lot,
  Matheus
0 件の賞賛
返信