PDA

View Full Version : Processing 2 different parts with 16F872 ?



Robson
- 21st June 2007, 01:11
Hi there,
Iīm a beginner in PicBasic and i want write my first program. It was really hard enough for me to change the configuration bits of this PIC cause of WDT problems.
Now my question is very simple.
Is it possible, that the PIC is running two different processes at the same time?
e.g. the 1st process only works once, when power up my board
and the second part is searching for a pressed button (matrix)
How can i solve this problem that both parts work simultanously?
Maybe someone can help me?
Iīm using MicroCode Studio v3.0.0.0, Pic Basic Pro Compiler v2.47 & MPLAB IDE V7.60
I hope that my english isnīt too bad and you can understand me...

'****************************************
'* Name : Matrix.BAS *
'* Author : Robson *
'* Notice : *
'* : All Rights Reserved *
'* Date : 20.06.2007 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************
' first process starts here
' this routine should run once by power up the PIC

for x = 1 to 5 ' Wait 10 Seconds
pause 2000
next x
PORTB.1 = 0

for x = 1 to 3 ' Wait 6 Seconds
pause 2000
next x
PORTB.1 = 1

for x = 1 to 2 ' Wait 4 Seconds
pause 2000
next x
PORTB.1 = 0
' this was the 1st part which only runs on startup
' for this time (20 seconds) the input on the matrix donīt work
goto main

' here starts the second Part which should run simultanously
' while the first part is running
main:
col1 = 1
col2 = 0
col3 = 0
savepos = pos

if row1 = 1 then
pos = 4
endif
if row2 = 1 then
pos = 3
endif
if row3 = 1 then
pos = 2
if savepos = 0 then goto main
endif
goto col2check
' etc .......
goto main
end

Ioannis
- 21st June 2007, 08:05
What you are looking for is a kind of multi-tasking. The solution for this are interrupts and the best resource is Darrel Taylor, http://www.pbpgroup.com/modules/wfsection/index.php?category=4

His is the author of Instant Interrupts. Study the examples and you will have the effect you want.

Ioannis

Darrel Taylor
- 21st June 2007, 08:38
Well, Thank you Ioannis!

And, for the keypad part, here's mister_e's keypad routine's being used with Instant Interrupts.
http://www.picbasic.co.uk/forum/showthread.php?p=37196

Should put you on the Fast Track.
<br>

Ioannis
- 21st June 2007, 08:54
Well, Thank you Ioannis!

And, for the keypad part, here's mister_e's keypad routine's being used with Instant Interrupts.
http://www.picbasic.co.uk/forum/showthread.php?p=37196

Should put you on the Fast Track.
<br>

You are welcome! But, don't you ever sleep? Here is 11 in the morning!

I suppose you are at west coast?

Ioannis

Darrel Taylor
- 21st June 2007, 10:06
Party all night, sleep all day.

It's just that the Party's on my computer.
So nobody else wants to come over. :(
<br>

Ioannis
- 21st June 2007, 10:59
Beers on me!

Unfortunately, we are too far away...!

Ioannis