on7nh
Joined: 05 Jun 2006 Posts: 41 Location: Belgium
|
32 bit Counter problem [Solved] |
Posted: Sat Aug 16, 2008 8:42 am |
|
|
Hello folks,
i have a strange prob,
i like to count a 10Mhz frequency
i use 30F4013 on counter 2 in 32 bit mode
if i print the result, i see only the lower16 bits,
10.000.000 = 0x989680
the result i see = 0x9680 or 35528
any sugestions?
Tnx, carl
Code: |
#include <30f4013.h>
#device adc=12
#FUSES NOWDT // Watch Dog Timer
#FUSES EC
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#fuses HS3_PLL16 // div by 3 and multiply the ext. clock of 40mhz by 8x
#FUSES PR_PLL // pll mode
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#define XTAL_FREQUENCY 128000000
#use delay(clock=XTAL_FREQUENCY)
#use rs232(stream = RS232, baud=115200,parity=N,xmit=PIN_F5,rcv=PIN_F4,bits=8)
int32 freq;
#include <math.h>
/////////////////////////////////////////////////////////////////////////////////////
/****************** 1 pps van GPS *******************/
#int_ext0
void EXT_ISR()
{
freq=0;
freq = get_timer23();
set_timer23(0);
}
/////////////////////////////////////////////////////////////////////////////////////
Void main()
{
set_tris_b(0b11000001);
EXT_INT_EDGE(L_TO_H);
setup_timer2(TMR_32_bit);
enable_interrupts(int_timer3);
set_timer23(0);
setup_timer2(TMR_EXTERNAL|TMR_DIV_BY_1);
enable_interrupts(INT_EXT0);
enable_interrupts(intr_GLOBAL);
printf("hello\n\r");
While(1)
{
delay_ms(400);
printf("FRQ %lu \n\r",freq);
}
}
| [/code]
Last edited by on7nh on Sat Aug 16, 2008 10:54 am; edited 1 time in total |
|