Problem with #define in microcontroller header file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with #define in microcontroller header file

Jump to solution
2,198 Views
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.
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
652 Views
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.   

View solution in original post

0 Kudos
4 Replies
652 Views
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 Kudos
652 Views
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 Kudos
653 Views
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 Kudos
652 Views
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 Kudos