Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Problem with generating interrupts at specified intervals

Status
Not open for further replies.

kar2on

Member level 1
Joined
Jul 30, 2005
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,728
4ms interrupt with pic

I seem to be having a problem generating interrupts at specified intervals. I use interrupt for sampling the ADC, on a PIC 18f452 microcontroller. I'm currently using mikroC , I've set the settings to 4Mhz Clock and under XT mode.

The hardware oscillator is a 4Mhz crystal.

Anyone know how I generate a 4ms Interrupt(250Hz). I've set the INTCON register to 0xA0 and the T0CON register to 0x80, Anyone know what TMROH and TMROL should be.

I've figured out that 4Mhz crystal oscillator has 1Mhz internal clock. So roughly about 4Mhz oscillation through a 1/2 prescaler , gives me 2Mhz oscilation.

This require 4ms*2Mhz gives me 8000 cycles. oxFFFF-8000 = E06F...

can anyone concur this result?
 

Mr_Programmer

Full Member level 3
Joined
Feb 21, 2002
Messages
153
Helped
9
Reputation
18
Reaction score
5
Trophy points
1,298
Activity points
1,424
Re: Interrupt timing

Hi,

I thought that the f_Osc is divided by 4 and then fed into the pic-core. This will mean that your program runs with 1MHz, if you set the prescaler to 2 you will have 500kHz frequency for you timer...

Regards...
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top