I need a big number in my firmware, So i choosed long for the job.
In the microchip's documents the long type provides 4Bytes for use:
So i created this variable (timeCounter):
In a interrupt of 100us of timer2 this variable is incremented:
Problem:
The variable is unsigned long but when i plot his value the max value achieved is aproximately 32725! and the variable is SIGNED!!!!
image:
The code below shows a sizeof(unsigned long) equals to 4bytes...
I've already disabled the compiler optimizations. Using PIC18f26k80.
=========================================================
code:
#include "main.h"
void main( void ){
char string[100];
unsigned long timeCounter;
setupHw();
initHw();
initSw();
while( true ){
clearWDT();
/*============================================================================*\
* Task3 (60s)
* Processo...
* Dependências:
\* ===========================================================================*/
if( f60s ){
f60s = false;
sprintf(string, "TimeCounter (60s): %d\n", timeCounter);
txStringUart1(string);
} // end da task2
}
}