32bit timer dspic
change build mode in mplab from RELEASE to DEBUG. in new versions there is a dropdown menu in the center of top toolbar. in older mplab you need to find some build options and change them to 'build for ICD2'. ICD2 uses first 80b of RAM, that's why you cannot see the variables which were placed there. see the screenshot below (MPLAB v8)
**broken link removed**
you should build in DEBUG mode for debugging, and in RELEASE mode for standalone operation (final code, test without debugger, etc.)
you need to inform Linker directly, that you are using icd2, so that it will put your variables above ICD2 restricted range (0x800 - 0x850).
your results are not in HEX, they are just integers. you can do type casting to convert them to floating point.
Code:
float var_float;
int var_int;
var_int=1234;
var_float=(float)var_int;
however - it is a good thing to avoid floating points, as they are heavy in computation. maybe there is a way to do that with integers (first multiply everything by 7.6E6, than do the math, divide the result...).
you can also check the math.h file - maybe there are some functions for tupe conversion, but probably you won't need any - type casting should be just enough - try googling it to learn more about it.
gl & hf
i hope that I have helped you a bit, as I am also an absolute beginner in dsPICs [;
EDIT:
there is another big mistake in your code:
Code:
T2CONbits.TCS=1; /*Using Internal Clock (Fosc/4)*/
T2CONbits.T32=0; /*TMRx and TMRy form a 16-bit timer*/
T2CONbits.TCKPS=0; /*Using 1:1 prescale value*/
T2CONbits.TGATE=0; /*Timer Gate Accumulation Disabled*/
T2CONbits.TSIDL=0; /*Continue in Idle Mode*/
T2CON = 0x00; //Stops the Timer2 and reset control reg.
notice that you first set or clear some bits in T2CON, and than you clear whole register, which makes your settings pointless - clear the T2CON before (you have that line commented):
Code:
T2CON = 0x00; //Stops the Timer2 and reset control reg.
T2CONbits.TCS=1; /*Using Internal Clock (Fosc/4)*/
T2CONbits.T32=0; /*TMRx and TMRy form a 16-bit timer*/
T2CONbits.TCKPS=0; /*Using 1:1 prescale value*/
T2CONbits.TGATE=0; /*Timer Gate Accumulation Disabled*/
T2CONbits.TSIDL=0; /*Continue in Idle Mode*/
if you clear the T2CON you don't need to clear every bit than:
Code:
T2CON = 0x00; //Stops the Timer2 and reset control reg.
T2CONbits.TCS=1; /*Using Internal Clock (Fosc/4)*/
// default:
/*TMRx and TMRy form a 16-bit timer*/
/*Using 1:1 prescale value*/
/*Timer Gate Accumulation Disabled*/
/*Continue in Idle Mode*/
the same is valid for your Timer3 initialization code.
EDIT2:
another thing is your clock source selection. datasheet for dspic33 (i use this family, but i suppose that in dspic30 it's the same) says:
bit 1 TCS: Timerx Clock Source Select bit
1 = External clock from TxCK pin
0 = Internal clock (FOSC/2)
and your code:
Code:
T2CONbits.TCS=1; /*Using Internal Clock (Fosc/4)*/
(dspic33 divides input freq by 2, dspic30 by 4 - don't worry about that, it makes no difference here)
something is wrong here... if the timers work, that's only because you reset T2CON and T3CON registers after setting some bits, so eventually you have TCS=0 for both timers... check that.
0x41 0x56 0x45!!