Problem with #define in microcontroller header file

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problem with #define in microcontroller header file

跳至解决方案
3,326 次查看
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,780 次查看
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,780 次查看
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,780 次查看
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,781 次查看
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,780 次查看
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 项奖励
回复