Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Interrupt Clock in PicBasic Pro

Status
Not open for further replies.

dHPorter

Newbie level 2
Joined
Jun 25, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,297
Hey, I'm new to forums in general so I apologize if I have any faux pas's (not sure how to make that plural).

I've been stuck on a program for the past week, using a PIC 16F88 and PicBasic Pro. I'm trying to run a program while being able to keep track of time using interrupts. I've looked at similar posts on this, but could not gain much from them.
I've tried this program to check if the interrupts are working, but no matter how I change the prescaler, I always get alternating 20 ms high, 10 ms low on the LED.

DEFINE OSC 8 'Internal RC Oscillator at 8 MHz
OSCCON.4 = 1
OSCCON.5 = 1
OSCCON.6 = 1

OPTION_REG.3 = 0 'Prescaler to TMR0
OPTION_REG.2 = 1 '1:256
OPTION_REG.1 = 1
OPTION_REG.0 = 1

INTCON.7 = 1 'Enable interrupts
INTCON.5 = 1 'Enables TMR0 interrupt
INTCON.2 = 0 'TMR0 overflow interrupt (not active)

led var porta.1
Counter var word
Counter = 0
i var byte

Main:
high led
goto main


disable
ClockInt:
for i = 0 to 2
low led
pause 1000
high led
pause 1000
next i
Counter = Counter + 1
INTCON.2 = 0
Resume
enable

End

The Counter variable is meant to count seconds, but I haven't gotten far enough to actually use it yet. Any insight would be greatly appreciated.
 

Check this: https://www.romanblack.com/one_sec.htm maybe you will get some idea :)
I've implemented this routine in Proton+, works like a charm.

That helps a lot with realizing how to structure it. I believe my problem has been improper variables and that I keep overflowing them. I've started to look into EEProm to store my values, but I've been reassigned to a different project at work. Guess I'll come back to this when I can. Thanks for your help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top